What is the output of the following HelloWorld.java?
public class HelloWorld {
public static void main(String[] args) {
if (2 < 1); {
System.out.println("Yes");
}
}
}
. . . . . . . . . . .
Answer
The output is "Yes".
Explanation
The ;
means, that no block is executed. The { ... }
is just a code block and not really related to the if
-statement.