以下在Java中不適用於我。 Eclipse抱怨沒有這樣的構造函數。我已經將構造函數添加到子類來解決它,但還有另一種方法可以做我想要做的事情嗎?如何爲抽象類的子類聲明默認構造函數?
public abstract class Foo {
String mText;
public Foo(String text) {
mText = text;
}
}
public class Bar extends Foo {
}
Foo foo = new Foo("foo");
+1你的回答比較好:P – 2010-02-08 22:00:45
謝謝。我的意思是 酒吧酒吧=新酒吧(「酒吧」); 我有你的解決方案實現,但我不知道你是否有實現Java構造函數。 – 2010-02-09 00:30:05