public class Main { public static void main(String[] args) { A a = new A(); B b = new B(); a = b;//父类引用指向子类对象 b = (B) a;//把B还原出来 } } class A { } class B extends A{ }
父类引用指向子类对象
最新推荐文章于 2023-08-19 17:31:25 发布
public class Main { public static void main(String[] args) { A a = new A(); B b = new B(); a = b;//父类引用指向子类对象 b = (B) a;//把B还原出来 } } class A { } class B extends A{ }