1.键值对存储一组对象

2.key值不能重复,value可以重复

3.具体的实现类,HashMap,treeMap,HashTable,LinkedHashMap

----------------------------------------------------------------------------------------

HashMap

数组+链表

默认的负载因子为0.75

默认数组容量大小为16

链表的默认长度为8,如果大于8会变成一个二叉树

Map 接口-LMLPHP

----------------------------------------------------------------------------

HashTable

Map 接口-LMLPHP

---------------------------------------------------------------------------------------

LinkedHashMap

Map 接口-LMLPHP

-------------------------------------------------------------------------------------------

import java.util.HashMap;
import java.util.Map; public class file { public static void main(String[] args) {
stringReader();
} private static void stringReader() {
Map<String,String> map = new HashMap<>();
map.put("1","lili");
map.put("2","lili2");
map.put("3","lili3");
//只会添加不存在相同key的值
map.putIfAbsent("3","lili4");
map.forEach((key,value)-> System.out.println(key+"->"+value));
}
}
04-16 10:57