Java单例模式
1,懒汉式
例如
public class Test01 {
private Test01(){};
private static Test01 test01;
public static Test01 getInstance(){
return test01=new Test01();
}
2,饿汉式
例如
public class Test01 {
private Test01(){};
private static Test01 test01=new Test01();
public static Test01 getInstance(){
return test01;
}
}