Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
SingletonEnum
public enum SingletonEnum {
/**
* 定义一个枚举的元素,它就代表了Singleton的一个实例。
*/
uniqueInstance;
/**
* 单例可以有自己的操作
*/
public void singletonOperation(){
//功能处理
System.out.println("best singleton!!!");
}
public static void main(String[] args) {
SingletonEnum.uniqueInstance.singletonOperation();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.