my code is as follows:
SomeType first = null;
if(true){
first = new SomeType();
}
first.setSomething();
In this case, I will get NullPointerExceptionthe last line at runtime, but NOT when debugging. The execution of the code after the if-statement seems to continue, although the if-statement is not fully processed. Everything works at runtime when I change the code to:
SomeType first = new SomeType();
first.setSomething();
It does not seem that code execution at runtime aligns with the expected order at compile time. In the above case, I always expect the "first" to be created before the ".setSomething ()" is called?
cobby source
share