Monthly Archives: March 2009

Historical collection classes

Arrays are defined to be fixed-size collections of the same datatype. They are the only collection that supports storing primitive datatypes. Everything else, including arrays, can store objects. When creating an array, you specify both the number and type of object you wish to store. And, over the life of the array, it can neither […]

Special collection implementations

Read-only collections After you’ve added all the necessary elements to a collection, it may be convenient to treat that collection as read-only, to prevent the accidental modification of the collection. To provide this capability, the Collections class provides six factory methods, one for each of Collection, List, Map, Set, SortedMap, and SortedSet. Collection unmodifiableCollection(Collection collection) […]


Comparable interface The Comparable interface, in the java.lang package, is for when a class has a natural ordering. Given a collection of objects of the same type, the interface allows you to order the collection into that natural ordering. The compareTo() method compares the current instance with an element passed in as an argument. If […]

Map interface

The interface is not an extension of the interface. Instead, the interface starts off its own interface hierarchy for maintaining key-value associations. The interface describes a mapping from keys to values, without duplicate keys, The alteration operations allow you to add and remove key-value pairs from the map. Both the key and value can be […]

List interface

The List extends the to define an ordered collection,permitting duplicates. The interface adds position-oriented operations, as well as the ability to work with just a part of the list. The position-oriented operations include the ability to insert an element or , get an element, as well as remove or change an element. Searching for an […]

Set interface

Set interface The Set interface extends the Collection interface and, by definition, forbids duplicates within the collection.The concrete Set implementation classes rely on the equals() method of the object added to check for equality. Implementations of the Set interface: HashSet and TreeSet. you will use a HashSet for storing your duplicate-free collection. For efficiency, objects […]

Collection Framework Design Concerns

Collection Framework Design Concerns To keep the design simple, instead of providing separate interfaces for optional capabilities, the interfaces define all the methods an implementation class may provide. However, some of the interface methods are optional.Because an interface implementation must provide implementations for all the interface methods, there needed to be a way for a […]

Collections Interface

Collections Interface : Basic adding or removing operation in Collection interface is done using the following * boolean add(Object element) * boolean remove(Object element) The Collection interface also supports query operations: * int size() * boolean isEmpty() * boolean contains(Object element) * Iterator iterator() Group operation Other operations the Collection interface supports are tasks done […]

Collections Framework

Collections Framework Sets: Sets have the following basic properties: * They contains only one instance of each item * They may be finite or infinite * They can define abstract concepts Map: A map is a special kind of set. It is a set of pairs, each pair representing a one-directional mapping from one element […]

Servlets in Distributed Environment

Servlets In Distributed Environment The following are our own rules of thumb for writing servlets to be deployed in a distributed environment: Consider that different instances of the servlet may exist on each different JVM and/or machine. Therefore, instance variables and static variables should not be used to store state. Any state should be held […]