Exception in thread “main“ java.lang.ClassCastException: test.SuperClass cannot be cast to test.SubC
我创建的类是如下情况,编译过程中没有报错,但是当我执行该代码的时候,终端出现以下异常Exception in thread "main" java.lang.ClassCastException: test.SuperClass cannot be cast to test.SubClass按照类的转型来说,superClass是父类对象,subClass1指向父类对象是向下转型,需要强转,按道理来说是没有错误的,但是还是报错。public class Test3 { public stat
原创
2020-07-21 11:40:59 ·
407 阅读 ·
0 评论