This week's book giveaway is in the Design forum.
We're giving away four copies of Building Microservices and have Sam Newman on-line!
See this thread for details.
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


Win a copy of Building Microservices this week in the Design forum!
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: 238


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: 9405
    
  20

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: 238

Thanks ankit for that such a good information to me
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: i want some information related to enum keyword
 
It's not a secret anymore!