Monday, July 25, 2016

Collection Framework


Before discussing about collection, we need to know about array disadvantages or problems with array.
1. Array can hold n numbers of  values but it has been fixed at time of its declaration. So its fix size
can not increase or decrease size of array
2. By using array , some time memory will be wasted.

int [] numbers= new numbers[10];

if we need to insert 8 values as above declared array then remaining memory will be wasted.
So array is not grow-able and heterogeneous. Array is not standard type data structure( not having more function for implementation)

So overcome  above problem we use Collection Framework. which is set of interfaces and classes.
Collection can hold homogeneous or heterogeneous objects , can increase or decrease size
according our requirement we can use redeemed methods.

Collection is a group of individual objects as  a single entity.
It contains several classes and interfaces which can be used to represent the group of objects as a single entity.

 9 key interfaces of collection framework:

1. collection
2. List
3. Set
4. SortedSet
5. navigableSet
6. Queue
7. Map
8. SortedMap
9. NavigableMap

But Collection interface having mainly below interfaces and classes

1. List interface
2. Set interface
3. Queue interface





Map interface having mainly below Interfaces classes :

1. hashMap
2. WeakhashMap
3. SortedMap
4. Identity hashMap