mardi 5 avril 2016

Best way to check default value of collections (List ,Set and Map) in java

What is the best way to check default value of collections (List ,Set and Map) in java ?

Example :

  1. List l = new ArrayList();
  2. Map m = new HashMap();
  3. Set s = new HashSet();

Condition check:

Wchich case it's better either isEmpty() or null ?

if (l.isEmpty() || l==null){ }

Aucun commentaire:

Enregistrer un commentaire