[代码] [Java]代码 package cn.itcast.apsliyuan.text; public class TypeDemo { public static void main(String[] args) { A a1=new A(); A a2=new B(); A b=a1; //C c=(C) a2;这句话会发作java.lang.Class http://www.fpnanchang.com/linked/20130210.do; CastException 反常,只能向上转型, } } class A{ } class B extends A{ } class C extends A{ } http://www.fpshijiazhuang.com/linked/20130210.do;
转载于:https://www.cnblogs.com/fpqqchao/archive/2013/02/11/2909949.html