Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Inner classes

 
Venkat Ramsimha
Ranch Hand
Posts: 127
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
class MyOuter2
{
private String x = "Outer2";
public static void main(String args[])
{
MyOuter2.MyInner i = new MyOuter2().new MyInner();
i.seeOuter();
}
void doStuff()
{
class MyInner
{
public void seeOuter()
{
System.out.println("Outer x is " + x);
} // close inner class method
} // close inner class definition
} // close outer class method doStuff()
} // close outer class


THE ABOVE PROGRAM WITH RESPECTIVE TO INNER CLASSES IS GIVING COMPILE TIME ERRORS.

Can anybody provide the explanation for the above?

Thanks,
venkat
 
Jas Oberai
Ranch Hand
Posts: 231
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
This is a K&B example,read the following statement stated there:



So,you need to do this instead,as shown in book:

Hope that helps!!!
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic