I am trying to end a loop when in two different instances: if it is empty and if the objects inside are null
. However, when the program executes the second if-statement, I get nullPointerException
, what am I doing wrong? (The statements are within a for
loop but there is nothing in between them)
if(ER.isEmpty()){
System.out.println(ER.size());
break;
}
if(ER.get(0).equals(null)){
System.out.println(ER.get(0));
break;
}