This week's book giveaway is in the JavaScript forum.
We're giving away four copies of Cross-Platform Desktop Applications: Using Node, Electron, and NW.js and have Paul Jensen on-line!
See this thread for details.
Win a copy of Cross-Platform Desktop Applications: Using Node, Electron, and NW.js this week in the JavaScript forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Inner classes  RSS feed

 
Venkat Ramsimha
Ranch Hand
Posts: 127
  • 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
  • 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!!!
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!