Collections in java is a framework that provides an architecture to store and manipulate the group of objects.
You can perform any operations such as inserting, manipulation, deletion, sorting, etc. in collections. This framework is provided in the java.util package. Objects can be stored, retrieved, and manipulated as elements of collections. Collection is a Java Interface.
Core Collection Interfaces
The core interfaces that define common functionality and allow collections to be manipulated independent of their implementation.
The 6 core Interfaces used in the Collection framework are:
· Iterator (Not a part of the Collections Framework) · SortedSet · Map · SortedMap
Iterator (Not a part of the Collections Framework)
Note: Collection and Map are the two top-level interfaces.
The Collection Interfaces:
The Collection Interface-: This enables you to work with groups of objects; it is at the top of the collections hierarchy.
The List Interface-: This extends Collection and an instance of List stores an ordered collection of elements.
The Set-: This extends Collection to handle sets, which must contain unique elements
The SortedSet-: This extends Set to handle sorted sets
The Map-: This maps unique keys to values.
The Map.Entry-: This describes an element (a key/value pair) in a map. This is an inner class of Map.
The SortedMap-: This extends Map so that the keys are maintained in ascending order.
The Enumeration-: This is legacy interface and defines the methods by which you can enumerate (obtain one at a time) the elements in a collection of objects. This legacy interface has been superseded by Iterator.
The Collection Classes:
AbstractCollection -: Implements most of the Collection interface.
AbstractList -: Extends AbstractCollection and implements most of the List interface.
AbstractSequentialList -: Extends AbstractList for use by a collection that uses sequential rather than random access of its elements.
LinkedList -: Implements a linked list by extending AbstractSequentialList.
ArrayList -: Implements a dynamic array by extending AbstractList.
AbstractSet -: Extends AbstractCollection and implements most of the Set interface.
HashSet -: Extends AbstractSet for use with a hash table.
LinkedHashSet -: Extends HashSet to allow insertion-order iterations.
TreeSet -: Implements a set stored in a tree. Extends AbstractSet.
AbstractMap -: Implements most of the Map interface.
HashMap-: Extends AbstractMap to use a hash table.
TreeMap -: Extends AbstractMap to use a tree.
WeakHashMap -: Extends AbstractMap to use a hash table with weak keys.
LinkedHashMap -: Extends HashMap to allow insertion-order iterations.
IdentityHashMap -: Extends AbstractMap and uses reference equality when comparing documents.
Vector -: This implements a dynamic array. It is similar to ArrayList, but with some differences.
Stack -: Stack is a subclass of Vector that implements a standard last-in, first-out stack.
Dictionary -: Dictionary is an abstract class that represents a key/value storage repository and operates much like Map.
Hashtable -: Hashtable was part of the original java.util and is a concrete implementation of a Dictionary.
Properties -: Properties is a subclass of Hashtable. It is used to maintain lists of values in which the key is a String and the value is also a String.
BitSet-: A BitSet class creates a special type of array that holds bit values. This array can increase in size as needed.