class Building {}
class House extends Building{}
public class ClassCasts{
public static void main(String [] args){
Building b=new House(); //创建子类实例 自动向上转型
Class<House> houseType=House.class;
House h=houseTyse.cast(b);
h=(House)b;
}
}
网友评论