It has been a while since I did something like this, so my memory may not be correct.
Java has a special keyword like this for accessing the outer class. The keyword is called outer.
So you would make this code:
System.out.println(this.i);//here im trying to print the value of i of inner class
System.out.println(i); // [1] here I want to print the value of i of enclosing class ??
diplay(); // [2] here I want to call the display method of enclosing class ???
into:
System.out.println(this.i);//here im trying to print the value of i of inner class
System.out.println( outer.i ); // [1] here I want to print the value of i of enclosing class ??
outer.display(); // [2] here I want to call the display method of enclosing class ???
Note I changed your typing error from diplay to display as well :)
[Edit]
My memory did fail me, so I tested it, when it didn't work I check out what it was that you do to get it to work.
Instead of using outer, you use the classname.this to get it.
So for instance, you would put enclosing.this instead of outer.
I changed the program and it compiled, but with no main method I could not run it.
Here is the changed program.
class enclosing
{
int i;
public enclosing()
{
i=10;
}
public void display()
{
System.out.println(i);
}
class inner
{
int i;
public inner()
{
this.i=20;
}
public void display()
{
System.out.println(this.i);//here im trying to print the value of i of inner class
System.out.println(enclosing.this.i); // [1] here I want to print the value of i of enclosing class ??
enclosing.this.display(); // [2] here I want to call the display method of enclosing class ???
}
}
}