views:

23

answers:

1

what is singleton instances of the enumeration class in java?

A: 

Perhaps you're talking aobut using an enum to implement the singleton pattern?

public enum Singleton {
   INSTANCE;
   public void singletonMethod() { ... }
}

Since enums were added to Java, this is the best (shortest, most correct) way to implement singletons.

Michael Borgwardt