Hi All ,
i want to understand below point, please help me to do so.
Even compiler know that it will never execute this if , still it will not complain.
However below code
But in this case compiler know that while block does not execute since false will be always false. Therefore it will give below error.
unreachable statement
But when we use true , then
while( true )
{
}
It will not complain , however it will cause infinite loop , so why compiler does not complain ? Why false inside if condition does not give any compiler error.
while( true )
{
System.out.println( "print me " );
}
System.err.println( "print me" );
If i put like this ,it will complain that for unreachable statement. Now compiler know that while loop is infinite loop.
Same thing is for do while and for loop too.
unreachable statement.