class Tag {
  Tag(int er) {
    System.out.println("Tag(" + er + ")");
  }
}class Card {
  Tag t1 = new Tag(1); // Before constructor
  Card() {
    // Indicate we're in the constructor:
    System.out.println("Card()");
    t4 = new Tag(4); 
  }
  Tag t2 = new Tag(2); // After constructor
  void f() {
    System.out.println("f()");
  }
  Tag t3 = new Tag(3); // At end
}public class OrderOfInitialization {
  public static void main(String[] args) {
    Card t = new Card();
    t.f(); // Shows that construction is done
  }
}
结果是:
Tag(1)
Tag(2)
Tag(3)
Card()
Tag(4)
f()
是不是因为所有的自变量在被使用调用之前(包括构造函数)要被初始化?所以Tag(2)Tag(3)先于Tag(4)?