Upcasting Downcasting

后端 未结 5 739
攒了一身酷
攒了一身酷 2020-12-21 17:41

I have a parent class class A and a child class class C extends A.

A a=new A();
C c=(C)a;

This gives me error. Wh

5条回答
  •  滥情空心
    2020-12-21 17:52

    In java there is concept that without upcasting u can't perform downcasting

    A a=new A(); C c=(C)a;

    in this case u try to perform downcast with out upcasting

提交回复
热议问题