1.Collection :-
- If we want to represent a group of individual objects as a single entity then we should go for Collection.
- Collection interface defines the most common methods which are applicable for any Collection object.
- In general collection interface is considered as root interface of Collection framework.
- Note:- there is no concrete class which implements collection interface directly.
2. List :-
- List is child interface of Collection.
- 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.
f 3. Set :-
- Set is child interface of Collection.
- If we want to represent a group of individual objects as a single entity where duplicates are not allowed and insertion order are not preserved then we should go for Set.
4. SortedSet :-
- SortedSet is child interface of Set.
- If we want to represent a group of individual objects as a single entity where duplicates are not allowed but all objects should be inserted according to some sorting order then we should go for SortedSet
5. NavigableSet :-
6. Queue:-
- It is child interface of Collection.
- If we want to represent a group of individual objects prior to processing then we should go for Queue.
- Ex: before sending a mail all mail id’s we have to store somewhere and in which order we saved in the same order mail’s should be delivered(First in First out) for this requirement
- Queue concept is the best choice.
- All the above interfaces (Collection, List, Set, SortedSet, NavigableSet and Queue) meant for representing a group of individual objects.
- If we want to represent a group of objects as key value pairs the we should go for Map Interface.
- Map is not he child interface of Collection.
- If we want to represent a group of individual objects as key value pairs then we should go for Map. Ex : Roll no. Name
- 102 Shivaji
- 103 Anil
- 104 Chandra
- Both key and value are objects.
- Duplicated keys are not allowed but values can be duplicated.
- It is the child interface of map.
- If we want to represent a group of key value pairs according to some sorting order of keys then we should go for SortedMap.
No comments:
Post a Comment