0% found this document useful (0 votes)
34 views

Collections in Java

The document discusses different Java collection interfaces - Collection, List, Set, SortedSet, NavigableSet, Queue, Map, SortedMap, and NavigableMap. It explains that Collection is the root interface that defines common methods for collections. List allows duplicates and preserves insertion order, while Set does not allow duplicates. SortedSet and NavigableSet sort elements, and Queue follows FIFO ordering. Map stores elements as key-value pairs. SortedMap and NavigableMap sort the keys in a Map.

Uploaded by

Umashankar
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
34 views

Collections in Java

The document discusses different Java collection interfaces - Collection, List, Set, SortedSet, NavigableSet, Queue, Map, SortedMap, and NavigableMap. It explains that Collection is the root interface that defines common methods for collections. List allows duplicates and preserves insertion order, while Set does not allow duplicates. SortedSet and NavigableSet sort elements, and Queue follows FIFO ordering. Map stores elements as key-value pairs. SortedMap and NavigableMap sort the keys in a Map.

Uploaded by

Umashankar
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 4

1.

Collection :-

o If we want to represent a group of individual objects as a single entity then we


should go for Collection.
o 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.
o Note:- there is no concrete class which implements collection interface directly.

2. List :-

 List is child interface of Collection.


o 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.

3. Set :-
o Set is child interface of Collection.
o 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.
o 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 :-
 It is the child interface of SortedSet.
 It defines several methods for navigable purpose.

 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.

o Note:-

 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.
 7. Map
 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.

 8. SortedMap
 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.
 9. NavigableMap(I)

 It is the child interface of sorted map, it defines


 Several utility methods for navigation purpose.
 TreeMap is the implementation class for NavigableMap.


https://javatechtube.blogspot.com/2019/03/spring-web-mvc-flow.html

You might also like