La colección de Java no tiene Map como parte del marco de la colección [duplicado]

If your look at marco de colección you will see the following, but Map is not in the list of interfaces. While we talk about map we say it is a part of collection framework, so if Map is a part of collection framework then why it is not in the interfaces list.

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 

preguntado el 24 de agosto de 12 a las 08:08

5 Respuestas

"The collection framework" and Collection interface are not the same thing.

Mientras que usted pueden regard a map as a collection of entries, Map doesn't support that directly - you can get a set of entries with the entrySet método.

But fundamentally you need to distinguish between "the collection framework" and the Collection de la interfaz del.

Respondido 02 ago 17, 02:08

Maps trabajar con key/value pairs, Mientras que el other collections trabajar con just values. Map maps keys to values. It allows its content to be viewed as a set of keys, a collection of values and a set of key-value mappings.

Check this following link. Answer by oracle.

Respondido 02 ago 17, 07:08

It's part of the collection framework but it doesn't implement the java.util.Collection de la interfaz del.

It's a different branch of the hierarchy. If you want, you can view it on the same level of the hierarchy as the Collection interface.

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

Respondido 24 ago 12, 10:08

Because Map is three collections: Keys, values and key-value pairs.

It's not easy to decide which one should be the default to iterate over, so it implements the interface three times (keySet(), values() y entrySet())

Respondido 24 ago 12, 08:08

Programas de Map interface is not an extension of the Collection interface. However, it is a structure for keeping collections of data.

Respondido 24 ago 12, 08:08

No es la respuesta que estás buscando? Examinar otras preguntas etiquetadas or haz tu propia pregunta.