vendredi 27 février 2015

Java if statement exception [on hold]

Define a List<Object> myList and put something in it so that its size is 1, and I print it out to make sure the size is actually 1.


Then for the following codes:



if(myList != null && myList.size() > 0){
print sth here
}


Then console shows nothing. Why? Since the size of myList is one.


But when I do this:



if (myList.size()>0){
print sth here
}


Then console do show something. What's the issue here?


Aucun commentaire:

Enregistrer un commentaire