class F {//父类
private int a = 1;
int b = 1;
static int c = 0;
F() {
c += 1;
System.out.println("c=" + c);
}
public void show() {
System.out.println("Fa " + a + " Fb " + (b++)+" c " +c);
}
}
class Z extends F {//子类
int e = 4;
public void show() {
System.out.println("f " + e);
// super.show();
// super.show();
}
public void show2() {
System.out.println("f2 " + e);
}
}
public class T {
public static void main(String[] args) {
// Object x[] = new String[3];
// x[0] = new Integer(0); //java.lang.ArrayStoreException
Z[] z = new Z[3];
F[] f;
f= z;
// F[] f = new F[3];
// //Z[] z = f ; 编译不通过
for(int i=0;i<3;i++){
// z[i] = new F(); 编译不通过
// f[i] = new F(); // 编译通过,运行时异常 java.lang.ArrayStoreException
z[i] = new Z();// 与f[i] = new FF();结果相同
}
z[2].show2();
z[2].show(); f[2].show();//结果相同
}
}