HashMap to return default value for non-found keys? November 6, 2022 by Tarik In Java 8, use Map.getOrDefault. It takes the key, and the value to return if no matching key is found.