MCPcopy Index your code
hub / github.com/BruceEckel/OnJava8-Examples / test

Method test

collectiontopics/MapOps.java:18–48  ·  view source on GitHub ↗
(Map<Integer,String> map)

Source from the content-addressed store, hash-verified

16 System.out.println(map.keySet());
17 }
18 public static
19 void test(Map<Integer,String> map) {
20 System.out.println(
21 map.getClass().getSimpleName());
22 map.putAll(new CountMap(25));
23 // Map has 'Set' behavior for keys:
24 map.putAll(new CountMap(25));
25 printKeys(map);
26 // Producing a Collection of the values:
27 System.out.print("Values: ");
28 System.out.println(map.values());
29 System.out.println(map);
30 System.out.println("map.containsKey(11): " +
31 map.containsKey(11));
32 System.out.println(
33 "map.get(11): " + map.get(11));
34 System.out.println("map.containsValue(\"F0\"): "
35 + map.containsValue("F0"));
36 Integer key = map.keySet().iterator().next();
37 System.out.println("First key in map: " + key);
38 map.remove(key);
39 printKeys(map);
40 map.clear();
41 System.out.println(
42 "map.isEmpty(): " + map.isEmpty());
43 map.putAll(new CountMap(25));
44 // Operations on the Set change the Map:
45 map.keySet().removeAll(map.keySet());
46 System.out.println(
47 "map.isEmpty(): " + map.isEmpty());
48 }
49 public static void main(String[] args) {
50 test(new HashMap<>());
51 test(new TreeMap<>());

Callers 1

mainMethod · 0.95

Calls 8

printKeysMethod · 0.95
printMethod · 0.80
valuesMethod · 0.80
isEmptyMethod · 0.80
getMethod · 0.65
nextMethod · 0.65
iteratorMethod · 0.45
removeMethod · 0.45

Tested by

no test coverage detected