本帖最后由 无气打火机 于 2013-8-1 18:47 编辑
package cn.itcast.bankqueue;
public class NumberMachine {
private NumberMachine(){}
private static NumberMachine instance = new NumberMachine();
public static NumberMachine getInstance(){
return instance;
}
private NumberManager commonManager = new NumberManager();
private NumberManager expressManager = new NumberManager();
private NumberManager vipManager = new NumberManager();
public NumberManager getCommonManager() {
return commonManager;
}
public NumberManager getExpressManager() {
return expressManager;
}
public NumberManager getVipManager() {
return vipManager;
}
}
这里的三个对象为什么要创建在单例里面???在外面创建不行么?用一个创建一个不可以么? |