class Sundae{
private Sundae(){}
static Sundae makeASundae(){
return new Sundae();
}
}
public class IceCream{
public static void main(String[] args){
Sundae x = Sundae.makeAsundae();
}
}
这个私有的构造函数的确很帅,但不知道有什么用,
在静态方法里直接进行初始化,而调用了内部的构造函数
class Sundae{
private Sundae(){}
static Sundae makeASundae(){
return new Sundae();
}
}
public class IceCream{
public static void main(String[] args){
Sundae x = Sundae.makeAsundae();
}
}
这个私有的构造函数的确很帅,但不知道有什么用,
在静态方法里直接进行初始化,而调用了内部的构造函数