It's not a secret anymore!*
The moose likes Java in General and the fly likes Enum constants must be the first statement in enum class? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Java in General
Bookmark "Enum constants must be the first statement in enum class?" Watch "Enum constants must be the first statement in enum class?" New topic
Author

Enum constants must be the first statement in enum class?

ZahidM Khan
Greenhorn

Joined: Apr 06, 2012
Posts: 8
Does the first statement of enum class must have to be a constant?

enum AnEnumClass{
CONSTANT1, CONSTANT2;
int a;
void aMethod(){}
}

VS

enum AnEnumClass{
int a;
void aMethod(){}
CONSTANT1, CONSTANT2;
}
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 60780
    
  65

Yes, the enum names must be first.


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
 
jQuery in Action, 2nd edition
 
subject: Enum constants must be the first statement in enum class?
 
Similar Threads
Question wrapper
enum "initialization circularity"?
Application globals / constants : Interface vs.public final
New user: Enum with switch case
Enum Declaration