dmitry.petrov
07/27/2017, 5:11 PMjava.lang.HashMap<int, int>
. What does it's get
method return if the key is absent?
It can't return null
, because it's not an int
.
It's actually mentioned here http://openjdk.java.net/jeps/218:
Null. Null is a valid value of every reference type, and is often used to represent "nothing is there." Primitive and value types, however, have no analogue of null. This is a challenge for methods like Map.get, which are defined to return null if the specified key cannot be found in the map.