Maps--HashMap, LinkedHashMap, TreeMap

来源:互联网 发布:g92调多头螺纹怎么编程 编辑:程序博客网 时间:2024/05/23 00:41

A map is a container object that stores a collection of key/value pairs. It enables fast retrieval, deletion, and updating of the pair through the key. A map stores the values along with the keys. The keys are like indexes. In list, the indexes are integers. 

In map, the keys can be any objects. 

A map can not contain duplicate keys.

Each key maps to one value.

A key and its corresponding value form an entry stored in a map.

If the map formerly contained an entry for this key. the old value is replaced by the new value and the old value associated with the key is returned.

 

The entries in the HashMap are in random order.

The entries in the TreeMap are increasing order of the keys.

The entries in the LinkedHashMap are in the order of their access, from least recently accessed to most recently. The most recently accessed entry is placed at the end of the map.

 

0 0