Map:The java.util.Map interface represents a mapping between a key and a value. The Map interface is not a subtype(子类型) of the Collectioninterface.Therefore it behaves a bit different from the rest of the collection types.java.util.Map接口表示键和值之间的映射。 Map接口不是Collection接口的子类型。因此它的行为与其他集合类型略有不同。
Few characteristics of the Map Interface are:
- A Map cannot contain duplicate(重复的)keys and each key can map to at most one value. Some implementations(实现类) allow null key and null value like the HashMapand LinkedHashMap, but some do not like the TreeMap.Map不能包含重复的键,每个键最多可以映射一个值。一些实现允许null键和null值,如HashMap和LinkedHashMap,但有些实现类不是这样,比如TreeMap。
- The order of a map depends on specific implementations, e.g TreeMapand LinkedHashMaphave predictable order, while HashMapdoes not.(未理解)
- There are two interfaces for implementing Map in java: Map and SortedMap, and three classes: HashMap, TreeMap and LinkedHashMap.在Java中有两个用于实现Map的接口:Map和SortedMap,以及三个类:HashMap,TreeMap和LinkedHashMap。
- Map的层次结构如下图所示:
原文地址:https://www.cnblogs.com/2sheep2simple/p/10651601.html
时间: 2024-09-29 15:38:57