9-Key Interfaces of Collection Framework
- Collection
- List
- Set
- SortedSet
- NavigableSet
- Queue
- Map
- SortedMap
- NavigableMap
- Collection:
- If we want to represent a group of invidual objects as single entity then we should go for Collection.
- Collection Inteface defines the most common methods which are applicable for any Collection object
- Note:- There is no concrete class which implements collection interface directly.
- List:
- List is child interface of Collection interface
- If we want to represent a group of individual objects as a single entity where duplicates are allowed and insertion order preserved then we should go for List.
- Set:
- It is child interface of Collection.
- If we don’t want duplicate and insertion order in not required then we should go for Set.
- SortedSet
- It is child interface of Set
- It doesn’t allow duplicate
- It inserts data in some sorted order.
- NavigaableSet
- It is child interface of SortedSet if defines several methods for navigations purpose
- Queue:
- It is child interface of Collection.
- If we want to represent a group of individual object prior to processing then we should go for queue.
- Map:
- Map is not the child interface of Collection
- If we want to store data in form of key-Value pair the should go for Map.
- Duplicates key are not allowed, but values can be duplicates
- SortedMap:-
- It is child interface of Map
- If we want to store data in sorting order of Key then this is good options
- NavigableMap
- It is child interface of sorted map
- It defines utility methods for navigation purpose.
0 comments: