• 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

enum and inner class

 
Ranch Hand
Posts: 68
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello,
I am studying enum and getting lots of questions.

I can declare a class in an enum. but my question is "how can I instantiate that class" ?



How can I instantiate a class that is declared in an enum ?

Thanks for the reply
 
Ranch Hand
Posts: 809
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by susan waters:
How can I instantiate a class that is declared in an enum ?



You need to create an instance of myenum by myenum.TEST or by myenum.SAMPLE or by myenum.ENGLISH. All will return you an instance of myenum but remember different instances of myenum.



Since Testing class is an inner class, so you require an instance of outer class like above.

If Testing is a static nested class, then you don't need any myenum instance and you code will work.



Naseem
[ July 27, 2006: Message edited by: Naseem Khan ]
reply
    Bookmark Topic Watch Topic
  • New Topic