HashMap to return default value for non-found keys?

The Solution to HashMap to return default value for non-found keys? is


In Java 8, use Map.getOrDefault. It takes the key, and the value to return if no matching key is found.

~ Answered on 2014-03-31 15:33:14


Most Viewed Questions: