当然可以,一般用于构造单例: public class Test{ public static Test instanse; private Test(){} public synchronized static getInstanse(){ if(null == instanse) instanse = new Test(); return instanse; } }
li_d_s(我是小鬼-我表情优哉药盒打开) 不错
打漏了一个单词,应该是public synchronized static Test getInstanse(){
public class Test{
public static Test instanse; private Test(){}
public synchronized static getInstanse(){
if(null == instanse) instanse = new Test();
return instanse;
}
}
?
构造方法用private ? 那这个类不会有子类了 其他应该没什么影响
============================================================
绝户类!!??呵呵