DESKTOP-7J91214_20200905-张军强
1.问题
单例
//饿汉模式单例
public class Sun{
private static final Sun SUN = new Sun();
private Sun(){
super();
}
public static Sun getInstance(){
return SUN;
}
}
//懒汉模式单例
public class Earth{
private static Earth earth ;
private Earth(){
super();
}
public static Earth getInstance(){
if(earth == null){
earth = new Earth();
}
return earth;
}
}
2.吐槽
考试还是容易紧张,总是犯很低级的错误,简单问题还是做错了,这次居然16的平方算错了。
近期评论