• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Innerclass doubt

 
Venkat Ramsimha
Ranch Hand
Posts: 127
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
class MyOuter5
{
private int x = 7;
public void makeInner()
{
MyInner in = new MyInner();
in.seeOuter();
}
class MyInner
{
public void seeOuter()
{
System.out.println("Outer x is " + x);
System.out.println("Inner class ref is " + this);
//System.out.println("Outer class ref is " + MyOuter.this);//LINE1
}
}
public static void main (String[] args)
{
MyOuter5.MyInner inner = new MyOuter5().new MyInner();
inner.seeOuter();
}

}
Hi All,
ON REMOVING THE COMMENTS WITH RESPECTIVE TO LINE1 ITS GiVING COMPILE TIME ERRORS.can anybody provide the explanation?

thanks,
venkat
 
Frederik Ericsson
Ranch Hand
Posts: 128
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
try with MyOuter5
that was the error. Its working now

with regards,
Chiyan
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic