Collection classes in java

Collection classes:

Collection classes are the concrete implementations of the collection interfaces.

Collection classes are given below:

1. HashSet: HashSet extends AbstractSet and implements the Set interface. It not maintains any order for its elements. It uses hash table for storage.

2. LinkedHashSet: LinkedHashSet extends HashSet and implements the Set interface. It maintains insertion order for its elements.

3. TreeSet: TreeSet extends AbstractSet and implements the NavigableSet interface. It maintains ascending order for its elements i.e. elements will be in sorted form.

4. ArrayList: ArrayList class extends AbstractList and implements the List interface. It uses dynamic arrays for storing elements. It maintains insertion order. ArrayList can contain duplicate elements. It is not synchronized.

5. LinkedList: LinkedList class extends AbstractSequentialList and implements the List and Deque interface. It uses linked list data structure to store elements. It can contain duplicate elements. It is not synchronized.

6. HashMap: HashMap extends AbstractMap class and implements the Map interface. It contains the elements in key-value pair form. It not maintains any order for its elements. It not allowed duplicate key. A HashMap can have only one null key and multiple null values.

7. LinkedHashMap: LinkedHashMap extends HashMap class and implements the Map interface. It contains the elements in key-value pair form. It maintains insertion order for its elements. It not allowed duplicate key. A LinkedHashMap can have only one null key and multiple null values.

8. TreeMap: TreeMap extends AbstractMap class and implements the NavigableMap interface. It contains the elements in key-value pair form. It maintains ascending order for its elements. It not allowed duplicate key. A TreeMap can have only one null key but can have multiple null values.   Next Topic: HashSet in java with example. Previous Topic: Enumeration interface in java with example.

Please follow and like us:
Content Protection by DMCA.com