2

For a Java Enum, what does INSTANCE mean (I see we can refer EnumName.INSTANCE for use methods defined in Enum)? Tried to find answer from web but failed.

thanks in advance, Lin

Lin Ma
  • 9,739
  • 32
  • 105
  • 175

1 Answers1

6

Enum values are typically expressed in upper case, Colour.RED, Colour.BLUE etc.

If you see INSTANCE it probably means someone is using the enum singleton pattern.

Community
  • 1
  • 1
Duncan Jones
  • 67,400
  • 29
  • 193
  • 254
  • Thanks Duncan, yes, I am talking about singleteon pattern of enum. And what is the benefit of using singleton pattern of enum, comparing to using singleton pattern of a normal Java class? – Lin Ma Mar 24 '15 at 01:07