LinkedHashMap

LinkedHashMap It is exactly same as HashMap,except the following differences. HashMap LinkedHashMap The underlying data structure is Hashtable. Insertion order is not preserve. Introduce in 1.2 version. The underlying data structure is Hashtable and LinkedList. Insertion order is preserve. Introduce in 1.4 version. In the above, if we are replacing HashMap LinkedHashMap, the following is […]

HashMap

HashMap The underlying data structure is Hashtable. Hashing insertion order is not preserve, because it based on Hashcode of keys. Duplicate keys are not allowed. But values can be duplicated. Heterogeneous objects allowed for both keys& value. Null key is allowed. Null values are allowed, any null of times. Difference between HashMap& Hashtable:- HashMap Hashtable […]

Map interface

Map interface If we want to represent group of objects as key- value pairs, then we should go for Map interface. Both key & value are objects only. Duplicated. Each key- value pair is consider as entry. hence a map is consider as a Set of entries. Collection interface mean for individual objects, where as […]

TreeSet

TreeSet The underlying data structure is balanced tree. Duplicate objects are not allowed. All elements will be inserted, according to some sorting order hence insertion is not preserve. Heterogeneous objects are not allow, violation leads ClassCastException. Constructors:- TreeSet t = new TreeSet (); // natural sorting order. creates an empty TreeSet object where all the […]

SortedSet

SortedSet It is the child interface set. If we want to represent a group of objects without duplicates, according to some sorting order, then we should go for SortedSet interface. The sorting order can be natural sorting order or customized sorting order. SortedSet defines the following six specific methods. Object first (); Object last (); […]

Set

Set It is the child interface of collection. If insertion order is not required & duplicate objects are not allowed. Then we should go for set interface. Set interface doesn’t contain any new method, hence we have to use only collection interface method. * image *         Constructor HasSet h = new […]

Stack

Stack It is the child class of vector & contains only or constructor. Stack s =new stack () Method of stack:- Object push ( object o ) //  for inserting an object Object pop ( object o ) // remove &returns top of the stack Object Peek () // returns top of the stack with […]

Vector

Vector The underlying data structure is resizable or growable array. Insertion order is preserve. Duplicate objects allow. Null insertion is possible. Heterogeneous objects are allow. Vector class implements Serialization, Cloneable & RandomAccess  interface. Best suitable for frequent operation is retrieval. Worst choice is Frequent operation is insertion or deletion on middle. Every method present in […]

LinkedList

LinkedList The underlying data structure for LinkedList is double LinkedList. Insertion order is preserve. Duplicate objects are allowed. Heterogeneous objects are allowed. Null insertion is possible. Implements Serializable & Cloneable interface but not Random Access. LinkedList is not suitable if our frequent operation is not retrieval operation. Constructors:- LinkedList l = new LinkedList (); creates […]

Array List

Array List The underlying  data structure is resizeable Array or growable Array. Insertion order is preserved. Duplicate objects are allowed. Hetrogenious objects are allowed. Null insertion is possible. Constructors of ArrayList ArrayList l = new ArrayList () ↔   creates an empty ArrayList object with default intial capacity 10. ↔  If arraylist reaches its max […]