Is there any way to make a key for searching the values in the collections and not returning null keys and values?
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Just implement your own
Mapwhich throws for exampleIllegalArgumentExceptioninstead of returningnull.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 isnullor not.