• 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

i want some information related to enum keyword

 
Ranch Hand
Posts: 251
Hibernate Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

enum just like a normal class...in the enum we also define the constructor and enum constructor invoked automatically....how this is possible..becauuse in the enum we create the variable of enum type, not the object....without object how it is possible the constructor called automatically in enum.

please give me answer which satisfied me.

Thanks
Sachin Singh
 
Ranch Hand
Posts: 2066
IntelliJ IDE Clojure Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Thakur Sachin Singh wrote:
enum just like a normal class...in the enum we also define the constructor and enum constructor invoked automatically....how this is possible..becauuse in the enum we create the variable of enum type, not the object....without object how it is possible the constructor called automatically in enum.

please give me answer which satisfied me.

Thanks
Sachin Singh



Those object variables are referring the object of the corresponding enum class, all are automatically happen because, they are enums

remove the keyword enum and see!
 
Sheriff
Posts: 9707
43
Android Google Web Toolkit Hibernate IntelliJ IDE Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The enum variables that we declare in the enum are actually instances of the enum. So the code
actually works something like this
 
Thakur Sachin Singh
Ranch Hand
Posts: 251
Hibernate Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks ankit for that such a good information to me
 
reply
    Bookmark Topic Watch Topic
  • New Topic