06 August 2017

Collections

Collection is a group of similar objects.
Java provides collections framework to use the data structures easily and efficiently for a group of objects.
collections

Main Interfaces of Collection framework are

List: Groups the similar objects.It can contain duplicate objects.LinkedList,ArrayList,Vector implement this interface.
ArrayList stores objects with index(order).So it is a ordered collection.Objects can be accessed with index.LinkedList stores object with a reference to next object in list.It is a unordered collection because objects can't be accessed with index.

Set:Groups the similar unique objects.It can't contain duplicates.
HashSet,TreeSet implement Set,SortedSet interfaces respectively.

Queue:Stores the objects in a List format.It follows FIFO(First In First Out) principle.

Map:Store objects as Key, Value pairs.
HashMap ,TreeMap implement Map interface.

Examples