see the below code you will realize the things
class Popcorn {
public void pop() {
System.out.println("popcorn");
}
}
class MyInner{
//----------------------------outer class
Popcorn p=new Popcorn() {
//----------------------------anonymous inner class
public void sizzle() {
System.out.println("anonymous sizzing popcorn");
}
};
public void priya() {
(new Popcorn() {
//----------------------------anonymous inner class
public void sizzle() {
System.out.println("anonymous sizzing popcorn");
}
}).sizzle();
//---------------------------------will print Popcorn class pop()
}
}
class Objective15 {
public static void main(
String[] args) {
MyInner outer=new MyInner();
outer.priya();
Popcorn myAccess=outer.p;
myAccess.pop();
// myAccess.sizzle();//--------------------------line1
}
}