Person p = new Student(); //父引用指向子类 Student s=(Student)p //向下转型,可以 Teacher t = (Teacher)p; //p指向的是student,而不是teacher
//此时报ClassCastException
其他常用异常:ArithmeticException(算术异常)
IndexOutOfBoundsException (数组下表越界异常)
NullPointerException (空指针异常)
NosuchElementsException(没有此元素异常)
标签:类型转换,指向,ClassCastException,Student,异常,Teacher From: https://www.cnblogs.com/cn-iwish/p/17180877.html