日期:2014-05-20 浏览次数:20755 次
public class Single { private Single() {} private static Single instance = new Single(); private static Single instance(){ instance = new Single(); return instance; } }
------解决方案--------------------
class Single { private Single() {} // private static Single instance = new Single(); //假如注释掉 private static Single instance; //这句话没有问题 // instance = new Single(); //这句活有问题,因为这条语句不能直接放在这里,必须放在某个方法里面或者放在初始化块里面。