Junior — Middle
Can you list the existing levels of nested hierarchy of collections in the used programming language?
sobes.tech AI
Answer from AI
In Java, collections are organized into a hierarchy of interfaces and classes. The main levels of the collection hierarchy:
-
Collection — the base interface for all collections except Map.
- List — an ordered list of elements, allowing duplicates (e.g., ArrayList, LinkedList).
- Set — a collection of unique elements (e.g., HashSet, TreeSet).
- Queue — a queue where elements are processed in a specific order (e.g., LinkedList, PriorityQueue).
-
Map — a key-value mapping, not inherited from Collection (e.g., HashMap, TreeMap).
Hierarchy example:
Iterable
└─ Collection
├─ List
├─ Set
└─ Queue
Map (separate hierarchy)
Each level adds its own methods and behavioral features of collections.