While it getreturns the same result for a value nulland a nonexistent key, it containsKeydoes not:
map.containsKey(1)will return true.
map.containsKey(2)will return false.
Also, if you iterate over the keys Map(using keySet()), it 1will be there, 2not it will be.
source
share