This document discusses the collection framework in Java. It provides an overview of the need for collections due to limitations of arrays. It then describes the key interfaces in the collection framework - Collection, List, Set, SortedSet, NavigableSet, Queue, Map, SortedMap, and NavigableMap. For each interface, it provides a brief description of its purpose and characteristics. It explains that collections allow storing heterogeneous data types with variable sizes, unlike arrays.
2. Need of collection framework?
Due to limitation of arrays
Arrays store homogenous data types only and fixed size
Collections allowed to store heterogeneous data types with growable size
Collection Framework is set of several classes and interfaces that helps to
achieve this target
3. 9 key interfaces of collection framework
Collection
List
Set
SortedSet
NavigableSet
Queue
Map
SortedMap
NavigbleMap
4. 1- Collection
Whenever we would like to represent a group of objects as a single entity,
we use Collection for the same
It is also known as root interface of collections framework but not
completely
There is no concrete class that implements collection interface directly
It defines most common methods which are applicable on any collection
object -
5. 2- List
List is child interface of Collection
Representing a group of object as a single entity with the condition that -
Duplicates are allowed
Insertion order is preserved
Duplicates identified by index
Preserving insertion order by index
Index has very important role
6. 3- Set
It is child interface of Collection
Representing a group of object as a single entity with the condition that -
Duplicates are not allowed
Insertion order is not preserved
7. 4- SortedSet
It is child interface of Set
Representing a group of object as a single entity with the condition that -
Duplicates are not allowed
Insertion order is not preserved
Objects should be stored in some sorted order
8. 5- NavigableSet
It is child interface of SoretdSet
It defines several methods for navigation purpose
TreeSet is the implementation class
9. 6- Queue
It is the child interface of Collection
If we want to represent a group of objects prior to processing then we
should go for Queue
For e.g. suppose we have to send email to 100 email id’s so we have to store it
somewhere and the emails will be delivered in the same order they were saved
10. Wait a min before next…
All discussed 6 interfaces Collection, List, Set, SoretdSet, NavigableSet,
Queue meant for representing a group of individual object as a single
entity
If we want a represent group of objects as key-value pairs then we should
go for Map interface
11. 7- Map
Map interface is not the child of Collection interface
If we want to represent a group of objects as key-value pairs then should
go for Map
Both key and value are objects
Duplicate key is not allowed, value can be duplicate
12. 8- SortedMap
It is the child interface of Map
If we want to represent a group of key value pairs as per some sorting
order then SortedMap is used
13. 9- NavigableMap
It is the child interface of SoretdMap
It defines several utility methods for navigation purpose
TrreeMap is the implementation class