//Anonymous class
class outer{
int x=80;
public void display(){
System.out.println("i am in outer class ");
}
}
class inner{
int y=60;
outer out=new outer(){
public void display(){
System.out.println("i am in inner class "+x);
System.out.println("i am in outer class "+y);
}
};
}
class inmain{
public static void main(String arg[]){
inner in=new inner();
in.out.display();
}
}
OUTPUT
class outer{
int x=80;
public void display(){
System.out.println("i am in outer class ");
}
}
class inner{
int y=60;
outer out=new outer(){
public void display(){
System.out.println("i am in inner class "+x);
System.out.println("i am in outer class "+y);
}
};
}
class inmain{
public static void main(String arg[]){
inner in=new inner();
in.out.display();
}
}
OUTPUT
No comments:
Post a Comment