Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Cloud/Virtualization forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Enum constants must be the first statement in enum class?

 
ZahidM Khan
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Pie
Posts: 64631
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yes, the enum names must be first.
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic