The Collections framework of Java contains data structures like set,list,map etc.Collections in Java enables us to manipulate group of objects .So a developer can use any of the structure while writing the application code.There are lot of classes and interfaces in Collections framework.The important interfaces and classes are shown below as a hierarchy layout.
Collections Framework in Java – Block Diagram
There is Collection interface.List and Set interfaces extending from Collection interface.
All List implementations are ordered by index position.The key methods in List interface are related to index.The methods include get(int index) , add(int index, Object arg)..etc.
a)ArrayList :ArrayList implements List interface. It implements the marker interface randomAccess too.ArrayList gives faster iteration.Since it is implementing RandomAccess it provides faster random access too.
b)LinkedList :In LinkedList the elements are doubly linked to each other. LinkedList is slower in iteration when compared with ArrayList . But insertion and deletion are faster in LinkedList. In latest versions of Java , LinkedList implements Queue interface too.So LinkedList is having properties of Queue also.
c)Vector: It is one of the legacy class with Java. Vector is almost similar to ArrayList.The difference is vector methods are thread safe. This causes a performance downfall for Vector when compared with ArrayList.
Set never allows duplication.Set uses equals() method to check whether two objects are equal or not. The classes which implements Set are listed below.
a)HashSet : In a HashSet items are arranged in a random order. The efficiency of this structure depends on the hashCode() implementation of objects inserted.
b)LinkedHashSet:It is the LinkedList version of HashSet. In LinkedHashSet the order of insertion is preserving.The efficiency of this structure also depends on the hashCode() implementation of objects being inserted.
c)TreeSet:It is a sorted collection.Default sorting order is ascending order.Using Comparable or Comparator instances , it is possible to change the order.
In Map data is storing as unique keys vs data .Remember, Map is not extending from Collection interface. Like Set ,Map also relying on equals() method to check whether two keys are equal or not.The classes which implements Map are listed below.