Write a program to display scope variable can be nexted.
0
/* Write a program to display scope variable can be nexted. */
class Scopevar{
public static void main(String args[]){
int x;
x=10;
if(x==10){
int y;
y=100;
System.out.println("y="+y);
}
System.out.println("x="+x);
}
}
/*
Output:
E:>javac Scopevar.java
E:>java Scopevar
y=100
x=10
*/
class Scopevar{
public static void main(String args[]){
int x;
x=10;
if(x==10){
int y;
y=100;
System.out.println("y="+y);
}
System.out.println("x="+x);
}
}
/*
Output:
E:>javac Scopevar.java
E:>java Scopevar
y=100
x=10
*/
0 comments: