Does JVM understand that these two lines in Method are logically connected and execute them line by line. Or is there a slight possibility that these lines could be swapped and a NullPointerException
thrown?
This Question is about a single threaded program.
public void foo(Object object) {
if(object == null) System.out.println("Oops!");
if(object.list == null) System.out.println("Oops!");
}
EDIT:
public void foo(Object object) {
if(object == null) return;
if(object.list == null) System.out.println("Oops!");
}