- Collection
- List
- Set
- SortedSet
- NavigableSet
- Queue
- Map
- SortedMap
- NavigableMap
1) Collection(I): If we want to represent a group of individual objects as a single entity then we should go for collection.
- The collection interface defines the most common methods which are applicable for any collection object.
- In the general collection, the interface is considered as the root interface of the collection framework.
- There is no concrete class that implements collection interface directly
Difference between collection and collections
- The collection is an interface. If we want to represent a group of the individual object as a single entity then we should go for the collection
- Collections is a utility class present in java. Util package to define several utility methods for collection object(like sorting, searching, etc)
2) List(I): It is the 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 must be preserved then we should go for List.
You can learn this in detail in our institute which provides advanced Java training in Delhi and Core java training in Delhi.
Note:- in 1.2version vector and stack classes are re-engineered to implement List Interface.
3) Set(I): It is the 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 not required then we should go for set Interface
4) SortedSet(I): It is the child interface of the set. If we want to represent a group of individual objects as a single entity where duplicates are not allowed and all objects should be inserted according to some sorting order, then we should go for a sorted set.
5) NavigableSet(I): It is the child interface of the sorted set. It contains several methods for navigation purposes.
6) Queue(Interface): it is the child interface of collection. If we want to represent a group of individual objects prior to processing then we should go for the queue. Usually, the queue follows first in first out the order but based on our requirement we can implement our own priority order also.
7) Map(Interface): Map is not the child interface of Collection.
- If we want to represent a group of objects as key-value pairs then we should go for a map.
- Both keys and values are objects only duplicate keys are not allowed but values can be duplicated.
8) SortedMap(Interface): It is a child interface of a map.
- If we want to represent a group of key-value pairs according to some sorting order of keys Then we should go for a sortedmap.
- In a sortedmap, the sorting should be based on key but not based on value.
9) NavigableMap(Interface): It is the child Interface of sorted maps it defines several methods for navigation purposes.