Created
June 27, 2012 07:28
-
-
Save doubledouble/3002227 to your computer and use it in GitHub Desktop.
SingletonEnum
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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