I'm very confused by the compilation error: can't reference a before the supercalss constructor has been called.
please read the following code and I look forward to explaination.
class
Test {
int y=1;
int a=6;
Test() {
this(a); /* Complilatrion error: can't reference a before the supercalss constructor has been called. However, when I added the "static" modifier before the declarion "int i=6;", the program works ok. */
}
Test(int x) {
if ( x > y )
a = y*6;
else
a = y*9;
a++;
System.out.println(a);
}
public static void main(
String [] args) {
Test t = new Test();
}
}