abstract class A1 {
public abstract void m1();
public void m2() {
System.out.println("Green");
} }
class A2 extends A1 {
public void m3(){
System.out.println("Green");
}
public void m1() {
System.out.println("Cyan");
}
public void m2() {
System.out.println("Blue");
} }
public class q19 extends A2 {
public void m1() {
System.out.println("Yellow");
}
public void m2() {
System.out.println("Pink");
}
public void m3() {
System.out.println("Red");
}
public static void main(String[] args) {
A2 tp = new A2();
tp.m1();
tp.m2();
((q19)tp).m3();//ClassCastException: A2 cannot be cast to q19
} }
java新手求解 這種runtime error是哪裡有問題 研究803亂改出來的