Granny's Programming Pearls
"inside of every large program is a small program struggling to get out"
JavaRanch.com/granny.jsp
Win a copy of Kotlin in Action this week in the Kotlin forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

a question of anonymous class  RSS feed

 
Stephen Lee
Ranch Hand
Posts: 74
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 7610
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
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!