views:

79

answers:

1

Hi, Is there any way to make a key for searching the values in the collections and not returning null keys and values?

A: 

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.

BalusC
thanks for your answer.
Johanna