public class Foo{
public static void main(String []args){
int a=10;
if(a==10)
int x=20;
}
}
While compiling above code, an error is thrown at compile.
But, in the below code it is fine. Why?
public class Foo{
public static void main(String []args){
int a=10;
if(a==10){
int x=20;
}
}
}
I don't get it. What exactly is happening in these? As I understand, we can write one statement after an if statement without curly braces (compound statement block).
Aucun commentaire:
Enregistrer un commentaire