MCPcopy Create free account
hub / github.com/crossoverJie/JCSprout / HashMapTest

Class HashMapTest

src/main/java/com/crossoverjie/basic/HashMapTest.java:15–42  ·  view source on GitHub ↗

Function: @author crossoverJie Date: 05/05/2018 12:42 @since JDK 1.8

Source from the content-addressed store, hash-verified

13 * @since JDK 1.8
14 */
15public class HashMapTest {
16 public static void main(String[] args) {
17 Map<String, Integer> map = new HashMap<>(16);
18 map.put("1", 1);
19 map.put("2", 2);
20 map.put("3", 3);
21 map.put("4", 4);
22
23 Iterator<Map.Entry<String, Integer>> entryIterator = map.entrySet().iterator();
24 while (entryIterator.hasNext()) {
25 Map.Entry<String, Integer> next = entryIterator.next();
26 System.out.println("key=" + next.getKey() + " value=" + next.getValue());
27 }
28 System.out.println("=============");
29
30 Iterator<String> iterator = map.keySet().iterator();
31 while (iterator.hasNext()){
32 String key = iterator.next();
33 System.out.println("key=" + key + " value=" + map.get(key));
34
35 }
36
37 System.out.println("=============");
38 map.forEach((key, value) -> {
39 System.out.println("key=" + key + " value=" + map.get(key));
40 });
41 }
42}

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected