I have a short question.
Lets assume we have a List
which is an ArrayList
called list
. We want to check if the list is empty.
What is the difference (if there is any) between:
if (list == null) { do something }
and
if (list.isEmpty()) { do something }
I'm working on an ancient code (written around 2007 by someone else) and it is using the list == null
construction. But why use this construction when we have list.isEmpty()
method...