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

Method main

collections/PetMap.java:9–19  ·  view source on GitHub ↗
(String[] args)

Source from the content-addressed store, hash-verified

7
8public class PetMap {
9 public static void main(String[] args) {
10 Map<String, Pet> petMap = new HashMap<>();
11 petMap.put("My Cat", new Cat("Molly"));
12 petMap.put("My Dog", new Dog("Ginger"));
13 petMap.put("My Hamster", new Hamster("Bosco"));
14 System.out.println(petMap);
15 Pet dog = petMap.get("My Dog");
16 System.out.println(dog);
17 System.out.println(petMap.containsKey("My Dog"));
18 System.out.println(petMap.containsValue(dog));
19 }
20}
21/* Output:
22{My Dog=Dog Ginger, My Cat=Cat Molly, My

Callers

nothing calls this directly

Calls 2

getMethod · 0.65
putMethod · 0.45

Tested by

no test coverage detected