标题: 关于饿汉式的代码 [打印本页] 作者: ileslie 时间: 2016-7-21 20:26 标题: 关于饿汉式的代码 public class Single
{
private static Single s=new Single();
private Single(){}
public static Single getInstance()
{
return s;
}
}
class Test2
{
public static void main(String[] agrs)
{
Single s1=Single.getInstance();
Single s2=Single.getInstance();
System.out.println(s1==s2);
}
}