Collection_FrameWrok1 |
|
Collection is a top level interface of java collection framework
where as Collections
is an utility class. Collections is further enhanced by Generics
handling compile time error due to wrong casting of data-types;
- Collections Class: is an utility class in java.util package. It
consists of only static methods which are used to operate on objects
of type Collections
- Collection.max()
- Collection.min()
- Collection.sort()
- Collections.synchronizedCollection()
- Collections.binarySearch()
- Collections.disjoint()
- Collections.reverse()
- Collection Interface : Collection is a root level interface of
the Java Collection Framework.

|
We all know that arrays are not resizable, and the size of the
arrays are fixed. To overcome this drawback of arrays. Collection
framework (Collections) were introduce in java from JDK 1.2. |
Collection is a root level interface of the Java Collection
Framework. Most of the classes in Java Collection Framework inherit from
this interface. List, Set and Queue are main sub interfaces of this
interface Java Collections interfaces is made up of a set of interfaces
for working with groups of objects. Using collection framework , users
can store the objects as List , Set, Queue or Map. |
Collections Framework:
- interfaces : These are abstract data types that represent
collections
- implementations : implementations of the collection interfaces
- algorithms: computations, such as searching and sorting, on
objects that implement collection interfaces.
|
Picture speaks thousands word: the image below is taken form the
provider. As indicated in the image, in Collections Framework the
interfaces "Collection" and "Map" have no direct

|
- Collection Frame work :
- The
Collection Interface
is the foundation of Collection Framework, few
important methods are listed below
- boolean add(Object obj): returns false for an existing
memeber, does not allow duplicates
- boolean addAll (Collection c) : returns true when
operation succeeded
- void clear() : removes all elements
- boolean contains (Object obj) : returns true when an
element is present.
- boolean containsAll(Collection c)
- boolean equals(Object obj)
- int hashCode(), int size()
- boolean isEmpty()
- Iterator itr()
- Object[] toArray
- Set interface extends Collection but forbids duplicates.
- Implement by: HashSet, LinkedHashSet, EnumSet ,
TreeSet
- List interface extends Collection, allowing duplicates
it uses some kind of indexes, for position oriented
operation.
- Implement by: Vector, Stack, ArrayList, LinkedList
- SortedSet extends Collection
- Map doest not extend Collection, operates with "Keys" to
"value", (presented under java.util), can't have duplicate
keys
- Implemented by: Hashtable, HashMap, LinkedHashMap,
WeakHashMap, IdentityHashMap
- Sorted map : Extends the Map interface.
- Tree Map: guarantees the order
- HashMap doesn't guarantee the order
|
Collection Interface :
|
|
|
|