Oct 26, 2018

Don't return null, use Collections.emptyList() in Java

Java has Collections.emptyList() which returns a predefined immutable list that we can use to avoid null
public List<Contact> getContacts() {
     if( .. there are no contacts .. )
       return Collections.emptyList();
}
By this way, you will minimize the chance of NullPointerExceptions and your code will be cleaner.