If dead codes are illegal in java, why does the following code compile fine without any compile time error :
int i= 5;
while (i<2) {
//some code here
}
Since the while condition is not getting satisfied, it will never go into the loop, so I assume this should be dead code. But it is getting compiled perfectly.