Possible Duplicate:
Cannot refer to a instance method while explicitly invoking a constructor
I have been trying to do this for long time.
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
class s {
public static void main(String[] args) {
bb sd = new bb();
System.out.println("sdfsdfsdfd");
}
}
This is the error that comes. I want to know why a instance variable can't be passed to a super class constructor? I suspect that it's because there is no instance accessible to the constructor.
Exception in thread "main" java.lang.Error: Unresolved compilation problem: Cannot refer to an instance field t while explicitly invoking a constructor