GeeCON Prague 2014*
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes Innerclass doubt Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "Innerclass doubt" Watch "Innerclass doubt" New topic
Author

Innerclass doubt

Venkat Ramsimha
Ranch Hand

Joined: Dec 28, 2004
Posts: 127
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

Joined: Apr 27, 2005
Posts: 128
try with MyOuter5
that was the error. Its working now

with regards,
Chiyan
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: Innerclass doubt