This week's giveaway is in the EJB and other Java EE Technologies forum.
We're giving away four copies of EJB 3 in Action and have Debu Panda, Reza Rahman, Ryan Cuprak, and Michael Remijan 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 EJB 3 in Action this week in the EJB and other Java EE Technologies 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: 224


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: 9280
    
  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: 224

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
 
Similar Threads
Enum reference confusion
URLyBird, File's fields length
doubt in enum
Casting and constructor!
Can we create a Object of Interface type