静的内部クラスの単一モード
- public class Singleton {
- /**
- * , , ,
- * ,
- */
- private static class SingletonHolder{
- /**
- * , JVM
- */
- private static Singleton instance = new Singleton();
- }
- /**
- *
- */
- private Singleton(){
- }
-
- public static Singleton getInstance(){
- return SingletonHolder.instance;
- }
- }
簡単明瞭かどうか見てみましょう.