Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

i want some information related to enum keyword

 
Thakur Sachin Singh
Ranch Hand
Posts: 248
Hibernate Java Spring
  • Mark post as helpful
  • send pies
  • 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
 
Abimaran Kugathasan
Ranch Hand
Posts: 2066
Clojure IntelliJ IDE Linux
  • Mark post as helpful
  • send pies
  • 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!
 
Ankit Garg
Sheriff
Posts: 9528
33
Android Google Web Toolkit Hibernate IntelliJ IDE Java Spring
  • Mark post as helpful
  • send pies
  • 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: 248
Hibernate Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks ankit for that such a good information to me
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic