public class test{
    private static test _instance;//存放實體
    private test(){}//創建實體
    public static test getInstance(){//取得實體
        if(_instance==null){//假如沒有實體 就創建他  否則用舊得
            _instance = new test();
        }
        return _instance;
    }
}

取得實體方法


 

test TInstance = test.getInstance();

 

arrow
arrow
    全站熱搜

    eric1300460 發表在 痞客邦 留言(0) 人氣()