File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes Please rectify this code on anonymous classes Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Java Interview Guide this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "Please rectify this code on anonymous classes" Watch "Please rectify this code on anonymous classes" New topic

Please rectify this code on anonymous classes

aishwarya mathur

Joined: Sep 03, 2004
Posts: 22
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

Joined: Aug 31, 2004
Posts: 11343

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 ]

"We're kind of on the level of crossword puzzle writers... And no one ever goes to them and gives them an award." ~Joe Strummer
I agree. Here's the link:
subject: Please rectify this code on anonymous classes
jQuery in Action, 3rd edition