Java Collections Framework
Java Collections Framework provides an architecture to store and manipulate the group of objects.
All collections frameworks contain interfaces, classes, algorithms.



List, Set, Map

ArrayList Class
It inherits AbstractList class and implements List interface.

Important:


Traversing the ArrayList
Two ways:
                //Traversing list through Iterator  
                Iterator itr=list.iterator();  
                while(itr.hasNext()){  
                    System.out.println(itr.next());  
                }  

                /******************************/

                // traversing using for-each loop
                for(String obj:al)  
                    System.out.println(obj);  
                }  
            

Complexity of ArrayList Linked List
It inherits the AbstractList class and implements List and Deque interfaces.

Important:

Complexity of Linked List ArrayList vs. Linked List
Search
ArrayList is faster with O(1) using get(int index)
Linked List has O(n)

Deletion
ArrayList has O(n) for worst case since it needs shifting if delete first element.
Linked List has O(1)

Insertion
ArrayList has O(n) because of shifting.
Linked List has O(1).

When to use Linked List and ArrayList:
* Frequent deletion and addition: Linked List
* Frequent search operations: ArrayList

Vector
Vector implements List interface. It implements a dynamic array just like ArrayList.

ArrayList vs. Vector
HashSet
It inherits the AbstractSet class and implements Set interface.

Important Difference between Set and List Example declaration and implementation syntax
HashSet set = new HashSet();
set.add("Hash");


Traverse through HashSet
use next()

Complexity LinkedHashSet
LinkedHashSet class is a Hash table and Linked list implementation of the set interface. It inherits HashSet class and implements Set interface.

Important Complexity TreeSet
TreeSet class implements the Set interface that uses a tree for storage. It inherits AbstractSet class and implements NavigableSet interface. The objects of TreeSet class are stored in ascending order.

Important Complexity Queue
Complexity
Priority Queue
The PriorityQueue class provides the facility of using queue. But it does not orders the elements in FIFO manner. It inherits AbstractQueue class.
An unbounded priority queue based on a priority heap.

Important Methods and Complexity
Deque Interface
Deque is a Queue in which you can add and remove elements from both sides.
It has two implementations: LinkedList and ArrayDeque.

Methods of Deque Interface ArrayDeque Class
The ArrayDeque class provides the facility of using deque and resizable-array. It inherits AbstractCollection class and implements the Deque interface.

Important