Skip to Content

O_ops: Never Return null For A Collection in Java

I was enjoying a small break between the meetings when my a co-worker asked me to help her out with some Java error in the code she was working on. She was giving me walk-through of the code and I small piece of code caught my attention. Apparently, the coder knew not to return null when returning a collection.

/* Check if the list is null \*/
if(matchingCountryList != null) {
	return matchingCountryList;
} else {
	return null;
}

Of course, it was not her code. 😉

Thank You!

Your comment has been submitted. It will appear on this page shortly! OK

Yikes, Sorry!

Error occured. Couldn't submit your comment. Please try again. Thank You! OK

Leave a comment