Java 杂谈

Java HashMap 与 HashSet

2018-05-10  本文已影响43人  聪明的奇瑞

HashMap

HashMap 内部结构

HashMap 扩容

HashMap 的 put()、get() 方法简述

HashMap 用法

HashMap<String,Integer> hashMap = new HashMap<>();
hashMap.put("a",1);
hashMap.put("b",2);
hashMap.forEach((k,v)->{
    System.out.println(k);
    System.out.println(v);
});

HashSet

HashSet 用法

HashSet<Integer> integers = new HashSet<>();
integers.add(1);
integers.add(2);
integers.forEach(i -> System.out.println(i));
上一篇 下一篇

猜你喜欢

热点阅读