I was told to use zerolength arrays instead of nulls in the program.But I couldn’t find how to use Zerolength array.Please Help me.
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.
The idea, in general, is that if a query returns “no results”, all things being equal, it is better to return an empty list (or array) than
null.The reason for that is it makes the client code a lot cleaner. You can still do something like this with an empty array:
If you tried the same with
nullyou would get a runtime exception. You can create an empty array using a few methods: