aspose file tools*
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes Enum Problem Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Soft Skills this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "Enum Problem" Watch "Enum Problem" New topic
Author

Enum Problem

Mohit G Gupta
Ranch Hand

Joined: May 18, 2010
Posts: 634

why cannot new constants of the
enum type MachineState be created ?



OCPJP 6.0 93%
OCPJWCD 5.0 98%
Ankit Garg
Sheriff

Joined: Aug 03, 2008
Posts: 9319
    
  17

You cannot instantiate enums on your own. enums only contain the constants declared inside of them. So you can do
Machine ob = Machine.ac
But you cannot do
Machine ob = new Machine();


SCJP 6 | SCWCD 5 | Javaranch SCJP FAQ | SCWCD Links
Abimaran Kugathasan
Ranch Hand

Joined: Nov 04, 2009
Posts: 2066

Ankit Garg wrote:You cannot instantiate enums on your own. enums only contain the constants declared inside of them. So you can do
Machine ob = Machine.ac
But you cannot do
Machine ob = new Machine();


That's the intention of the enum.


|BSc in Electronic Eng| |SCJP 6.0 91%| |SCWCD 5 92%|
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Enum Problem