Returns either the value of the specified Key in Map or the Default Value if the Key is not available.
Sample Code 1
Map<String,String> intMap = new HashMap<String,String>();
strMap.put("Key1","Value1");
strMap.put("Key2", "Value2");
System.out.println(strMap.getOrDefault("Key1", "Value5")); // prints Value1
Sample Code 2
Map<String,String> strMap = new HashMap<String,String>();
strMap.put("Key1","Value1");
strMap.put("Key2", "Value2");
System.out.println(strMap.getOrDefault("Key5", "Value5")); // prints Value5
Sample Code 1
Map<String,String> intMap = new HashMap<String,String>();
strMap.put("Key1","Value1");
strMap.put("Key2", "Value2");
System.out.println(strMap.getOrDefault("Key1", "Value5")); // prints Value1
Sample Code 2
Map<String,String> strMap = new HashMap<String,String>();
strMap.put("Key1","Value1");
strMap.put("Key2", "Value2");
System.out.println(strMap.getOrDefault("Key5", "Value5")); // prints Value5