这些是实例字段
private Bread b = new Bread();private Cheese c = new Cheese();private Lettuce l = new Lettuce();
它们仅在创建实例时存在(执行)。
在程序中运行的第一件事是
public static void main(String[] args) { new Sandwich();}超级构造函数被隐式地称为每个构造函数中的第一件事。之前
System.out.println
class Meal { Meal() { System.out.println("Meal()"); }}class Lunch extends Meal { Lunch() { System.out.println("Lunch()"); }}class PortableLunch extends Lunch { PortableLunch() { System.out.println("PortableLunch()");}}在以后
super()的调用,实例字段在构造函数代码之前再次实例化。
顺序相反
new Sandwich(); // prints last// the instance fieldssuper(); // new PortableLunch() prints thirdsuper(); // new Lunch() prints secondsuper(); // new Meal(); prints first



