开发者

It is related to core java enums

what is singleton instances of the enumer开发者_如何学JAVAation class in java?


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜