GeeCON Prague 2014*
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes i want some information related to enum keyword Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "i want some information related to enum keyword" Watch "i want some information related to enum keyword" New topic
Author

i want some information related to enum keyword

Thakur Sachin Singh
Ranch Hand

Joined: Jun 15, 2010
Posts: 232


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


SCJP 6- 91%, IBM DB2, IBM RAD Certified
Abimaran Kugathasan
Ranch Hand

Joined: Nov 04, 2009
Posts: 2066

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!


|BSc in Electronic Eng| |SCJP 6.0 91%| |SCWCD 5 92%|
Ankit Garg
Sheriff

Joined: Aug 03, 2008
Posts: 9303
    
  17

The enum variables that we declare in the enum are actually instances of the enum. So the code
actually works something like this


SCJP 6 | SCWCD 5 | Javaranch SCJP FAQ | SCWCD Links
Thakur Sachin Singh
Ranch Hand

Joined: Jun 15, 2010
Posts: 232

Thanks ankit for that such a good information to me
 
GeeCON Prague 2014
 
subject: i want some information related to enum keyword