When I'm compiling this code
public static void main(String [] args) {
int x = 0;
while(false)
{
System.out.println(hello);
}
}
it is showing compile time error unreachable code.
But when I modified this code to
public static void main(String [] args) {
int x = 0;
boolean result = false;
while(result)
{
x=4;
}
}
it's working fine.
Can somebody tell me the reason behind this behavior.