日期:2014-05-20 浏览次数:20747 次
public class MyManager{ private static class MyManagerContainer{ private static MyManager instance = new MyManager(); } public static MyManager getInstance(){ return MyManagerContainer.instance; } private MyManager(){ } }
public class MyManager{ private static MyManager instance; public static getInstance(){ return instance; } public MyManager(){ if(instanct!=null){ throw new IllegalStateException("Already exist"); } instance = this; } }