lundi 8 juin 2015

Are the conditional statements if(true) and if(false) evaluated at compile time in java?

The following code compiles successfully:

int x;
if(true)
  x=3;
System.out.println(x);

Does that mean the if condition is evaluated at compile time? If so why does the following code not throw Unreachable Statement error?

if(true)
  return;
return;  //No error

What's the difference?

Aucun commentaire:

Enregistrer un commentaire