If I have a piece of code like :
if(condition)
int a = 0;
When I compile it, Java compiler produces an error .class expected .
I know that when we don't use braces, we can use only 1 statement after if
.
And I also know that I will not be able to use the int
variable a
because as soon as the ;
is encountered, the program comes out of if
, and the variable a
loses it's scope.
So, I am not surprised that an error is produced.
What surprises me is that the error says '.class' expected.
So what is Java compiler trying to say?
Aucun commentaire:
Enregistrer un commentaire