Java Reference
In-Depth Information
class Inner2 extends Inner1 {}
^
OK, maybe it's not so helpful, but we'll work on that. The problem is that the compiler-generated
default constructor for Inner2 cannot find an appropriate enclosing instance for its super
invocation. Let's look at the program with the default constructors included explicitly:
public class Outer {
public Outer() {}
class Inner1 extends Outer {
public Inner1() {
super(); // invokes Object() constructor
}
}
class Inner2 extends Inner1 {
public Inner2() {
super(); // invokes Inner1() constructor
}
}
}
Now the error message gives a bit more information:
Outer.java:12: cannot reference this before
supertype constructor has been called
 
 
Search WWH ::




Custom Search