I have this:
while(victim.getHealth() > 1 && !victim.getName().equals(this.getName())) {
victim.hurt();
}
Now I noticed that in special occasions victim.getName() will return null (this is wanted behavior). But when that's the case I am expecting a NullPointerException to occur because we are basically calling null.equals(this.getName()) for the second condition.
However this doesn't happen. If I switch the order of the loop-conditions, e.g.
while(!victim.getName().equals(this.getName()) && victim.getHealth() > 1) {
victim.hurt();
}
The NullPointerException will be thrown when getName() returns null.
Also: If this was || condition and not &&, in java the programm will stop checking for true condition once it found one right?