public class Main{
public static void main(String[] args) {
int x;
int y=10;
if(y==10){
x=y;
//System.out.println("x is "+x);
}
System.out.println("x is "+ x);
}
}
When executed this says x not initialized?Cannot understand why? But the commented print statement is executed and the later one is removed then it works fine?
Aucun commentaire:
Enregistrer un commentaire