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()");
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() 详细点谢谢大家了
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()");
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() 详细点谢谢大家了
然后是构造函数的输出,然后是构造函数里面t3的输出,然后有t.f()的输出
谢谢\明白了,
谁能留个MSN吗?有问题指导我下\我在广州\华南理工这边
希望能交个师傅(当然也希望是朋友)