I'm having a difficult time understanding why the second string does not print. Even if I comment out the "third string" print line, there is no output.
public class SecretMessage {
public static void main (String [] args) {
int aValue=4;
if (aValue > 0){
if (aValue == 0)
System.out.print("first string ");
}
else
System.out.println("second string ");
System.out.println("third string ");
}
}
Why doesn't the "second string" print? I thought that anything under the else block would be executed, so both second and third string should be printed.
Thanks in advance!
See Question&Answers more detail:os