There is no map in the Java collection as part of the collection structure

If you look at the infrastructure of the collection , you will see the following, but Map is not included in the list of interfaces. Although we are talking about a map, we say that it is part of the structure of the collection, so if Map is part of the structure of the collection, then why is it not in the list interfaces.

 java.util
Interface Collection

All Known Subinterfaces:
    BeanContext, BeanContextServices, List, Set, SortedSet

All Known Implementing Classes:
    AbstractCollection, AbstractList, AbstractSet, ArrayList, BeanContextServicesSupport, BeanContextSupport, HashSet, LinkedHashSet, LinkedList, TreeSet, Vector 
+5
source share
5 answers

Mapsworks with key/value pairs, and other collectionsworks with just values. The map maps keys to values. It allows you to view its contents as a set of keys, a set of values, and a set of key value mappings.

. oracle. https://docs.oracle.com/javase/tutorial/collections/

+5

" " Collection - .

, Map - entrySet.

" " Collection.

+8

Map : , -.

, , (keySet(), values() entrySet())

+2

This is part of the structure of the collection, but it does not implement the interface java.util.Collection.

This is another branch of the hierarchy. If you want, you can view it at the same hierarchy level as the Collection interface.

The Collection interface is implemented (is the root) of List-like Collections, while Map is implemented (is the root) of collections of the KEY-VALUE type.

+2
source

An interface is Mapnot an extension of an interface Collection. However, it is a structure for storing data collections.

0
source

All Articles