Does anyone know why:
public void foo()
{
System.out.println(\"Hello\");
return;
System.out.println(\"World!\");
}
Would be rep
The if (true) is a little more subtle than "unreachable"; because that hard-coded return will always make the following code unreachable, but changing the condition in the if could make the following statement reachable.
Having a conditional there means that there's a chance condition could change. There are cases where something more complicated than a true is in the parentheses, and it's not obvious to the human reader that the following code is "deadened," but the compiler notices, so it's able to warn you about it.
Eclipse is mentioned here, and it makes things seem a little more complicated to the user; but actually underneath Eclipse is just a (very sophisticated) Java compiler that happens to feature a lot of switches for warnings etc. that Eclipse can switch on and off. In other words, you don't get quite the breadth of different warnings/errors from a straight javac compile, nor do you have convenient means to turn all of them on or off. But it's the same deal, just with more bells and whistles.