向上转型(子类→父类):(自动完成)
父类名称 父类对象 = 子类实例 ;
向下转型(父类→子类):(强制完成)
子类名称 子类对象 = (子类名称)父类实例 ;
对象名 instanceof 类
判断指定的变量名此时引用的真正类型是不是当前给出的类或子类;
我的总结:对象的类型和类必须有继承关系
Eg:
class A extends B{}
B b = new A();
If(b instanceof A){ ...
}