• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

anonymous inner class

 
Ranch Hand
Posts: 64
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
An anonymous inner class can have a static initializer . Is this statement true or false ?
I think the answer is true. Am i right?
 
Ranch Hand
Posts: 504
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Inner classes cannot have static declarations. Only top level nested classes can contain static blocks or members.
 
Ranch Hand
Posts: 150
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Vad Fogel:
Inner classes cannot have static declarations. Only top level nested classes can contain static blocks or members.


Sorry, but I disagree. I maybe wrong but Inner classes can have final static members.
Cheers
Harwinder
 
Ranch Hand
Posts: 64
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
hi,
As per what i have read - anonymous casses do not have constructors but they do have static initializers.
Hope m correct.
mona(varijas mom)
 
Vad Fogel
Ranch Hand
Posts: 504
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Marlene Miller:
Oh this is fun. I hope you don't mind.
static final variables that have initializers that are constant expressions
Vad and Harwinder, I am just teasing you. You are my friends.
[ November 13, 2003: Message edited by: Marlene Miller ]


Marlene, the question was about static initializers that you can put into anonimous inner classes, not constant expressions! Ok, what I previously said about static members was only partially correct - you can have static constant fields in there...
reply
    Bookmark Topic Watch Topic
  • New Topic