This week's book giveaway is in the Jobs Discussion forum.
We're giving away four copies of Customer Requirements for Developers and have Marcho Behler on-line!
See this thread for details.
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes a question of anonymous class Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Customer Requirements for Developers this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "a question of anonymous class" Watch "a question of anonymous class" New topic
Author

a question of anonymous class

Stephen Lee
Ranch Hand

Joined: Dec 11, 2001
Posts: 74
I have a problem....
is this sentence true or false?
An anonymous class can only be created within the body of a method. thx!
Valentin Crettaz
Gold Digger
Sheriff

Joined: Aug 26, 2001
Posts: 7610
No, you can also create an anonymous class inside an (static or non-static) initializer block and in member initialization also.

HIH

------------------
Valentin Crettaz
Sun Certified Programmer for Java 2 Platform


SCJP 5, SCJD, SCBCD, SCWCD, SCDJWS, IBM XML
[Blog] [Blogroll] [My Reviews] My Linked In
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
 
subject: a question of anonymous class
 
It's not a secret anymore!