Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP 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: 65115
89
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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic