Is there any way to make a key for searching the values in the collections开发者_如何转开发 and not returning null keys and values?
Just implement your own Map
which throws for example IllegalArgumentException
instead of returning null
.
All with all, this makes no sense. If you want, just test the existence of the key using Map#containsKey()
and/or check if the returned value is null
or not.
精彩评论