关于初始化 基础知识的问题
class Tag {
Tag(int marker) {
System.out.println("Tag(" + marker + ")");
}
}
class Card {
Tag t1 = new Tag(1); // Before constructor
Card() {
// Indicate we're in the constructor:
System.out.println("Card()");
t3 = new Tag(33); // Re-initialize t3
}
Tag t2 = new Tag(2); // After constructor
void f() {
System.out.println("f()");
}
Tag t3 = new Tag(3); // At end
}
public class Flower { //
public static void main(String[] args) {
Card t = new Card();
t.f(); // Shows that construction is done
}
}
请大家给在程序后面我加注释\我的要求是把整个程序解释清楚\因小弟目前在看THINKING JAVA
特别我不明白为什么能打印6个值
Tag(1)
Tag(2)
Tag(3)
Card()
Tag(33)
f() 详细点谢谢大家了