Possible Duplicate:
Cannot refer to a instance method while explicitly invoking a constructor
我已经尝试了很长时间了。
public class bb extends test {
int t = 23;
public bb() {
super(t); //**This is the place that error comes**
// TODO Auto-generated constructor stub
}
public bb(int v) {
}
}
public class test {
public test() {
// TODO Auto-generated constructor stub
}
public test(int v) {
// TODO Auto-generated constructor stub
}
}
Controller 类
class s {
public static void main(String[] args) {
bb sd = new bb();
System.out.println("sdfsdfsdfd");
}
}
这是来的错误。我想知道为什么不能将实例变量传递给父类(super class)构造函数?我怀疑这是因为构造函数没有可访问的实例。
线程“main”中的异常 java.lang.Error: Unresolved 编译问题: 显式调用构造函数时无法引用实例字段 t