| 泛型类在转换类型是,好像是不允许的....还是有其他的语法,为啥会出现这种现象。 复制代码class FanXingDemo2 
{
        public static void main(String[] args) 
        {
                A<String> a = new B<String>();
                a.show("Hello");
                /*这样转会出现错误*/
        //        B<String> b = (A<String>)a;
        //        b.show("oye");
                C c = new D();
                D d = (D)c;//这样是可以的
        }
}
class A<String>
{
        void show(String str){
                System.out.println("A.."+str);
        }
}
class B<String> extends A<String>
{
        void show(String str){
                System.out.println("B.."+str);
        }
}
class C
{
}
class D extends C
{
}
 |