這就是我想要做的(在Java中1.6):如何在Java中實現構造函數包裝?
public class Foo {
public Foo() {
Bar b = new Bar();
b.setSomeData();
b.doSomethingElse();
this(b);
}
public Foo(Bar b) {
// ...
}
}
編譯器說:
call to this must be first statement in constructor
有什麼解決方法嗎?
這是否真的回答第二個構造函數上的郵件? – RonU 2010-10-07 12:47:47
*回覆郵件* ??? – 2010-10-07 12:51:59
@RonU - 國際海事組織,我的回答直接解決了OP的問題。如果您不同意,請解釋原因。 – 2010-10-07 13:18:11