java map.getordefault code example
Example: getordefault java
Map<String, String> map = new HashMap<>();
map.put("1", "Foo");
//search for the entry with key==1, since present, returns foo
System.out.println(map.getOrDefault("1", "dumnba"));
//search for the entry with key==2, since not present, returns dumnba
System.out.println(map.getOrDefault("2", "dumnba"));