多态的相关问题
class A {public void f() {
System.out.println("AAAA");
}
}
class B extends A {
public void f() {
System.out.println("BBBB");
}
public void g() {
System.out.println("CCCC");
}
}
public class Test4 {
public static void main(String[] args) {
A aa = new A();
B bb = new B();
aa = bb;
bb = (B)aa;
aa.f();
aa.g();
}
}
不知道哪里出错了,我想要实现aa.g()