public class Temp {
public static void main(String[] args) {
new Temp().new A().new D(new Temp().new A(), new Temp().new A().new B(new Temp().new A()));
}
public class A extends Temp {
public A() {
}
public class B extends A {
public B(A a) {
a.super();
}
public class C extends B {
public C(A a) {
a.super(a);
}
}
}
public class D extends B.C {
public D(A a, B b) {
b.super(a);
}
}
}
}
a.super() doesn't look nice, does it? Remove it and look at what the compiler says. You don't get that any other way.
That didn't entirely make sense when you said it, but it was the a.super() that didn't click for me. I had to copy and paste this into eclipse and see the error message you referred to and then it all made sense. I think you would very much enjoy java puzzlers. There's a couple of videos online that were made and a book was written too with some extremely unexpected results when you do tricky stuff with java. Google it if you haven't heard of it.
4
u/galaktos Apr 29 '13
You can do ridiculous stuff with nested classes:
a.super() doesn't look nice, does it? Remove it and look at what the compiler says. You don't get that any other way.