This week's book giveaway is in the Jython/Python forum.
We're giving away four copies of Murach's Python Programming and have Michael Urban and Joel Murach on-line!
See this thread for details.
Win a copy of Murach's Python Programming this week in the Jython/Python forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Please rectify this code on anonymous classes  RSS feed

 
aishwarya mathur
Greenhorn
Posts: 22
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi All,

This below code is from Khalid's (Page No 311).I'am trying to understand what are the accessible declarations in anonymous class which extends Base.So I have added some printout statements to check out what variables are accessed and how.But somehow, I'am not able to compile the program.Can you please correct the code.

 
marc weber
Sheriff
Posts: 11343
Java Mac Safari
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Got errors?

Your System.out.println statements are in the anonymous class body definition. They need to be in a method.

(I know it looks like a method, but you're actually calling the Base constructor, then slipping in a class definition with the braces. So the braces represent a class body -- not a method body.)
[ September 24, 2004: Message edited by: marc weber ]
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!