class Sundae{
//以下两个方法缺省为friendly
Sundae(){}
Void f() {System.out.println(“Sundae.f()”);
}
public class IceCream{
public static void main(String[] args){
Sundae x = new Sundae();
x.f();
}
}
class Sundae{
private Sundae(){}//只能在Sundae class中被调用
Sundae(int i) {}
static Sundae makASundae() {
return new Sundae();
}
}
public class IceCream{
public static void main(String[] args){
// Sundae class中构造函数Sundae()是private,
// 所以不能用它进行初始化
//Sundae x = new Sundae();
Sundae y = new Sundae(1);//Sundae(int)是friendly,可以在此调用
Sundae z = Sundae.makASundae();
}
}