class Father<T>{ T t; Father(T t){ this.t=t; } public void fatherPrint(){ System.out.println("father's "+t); } } class Son<T> extends Father{ Son(T t) { super(t); } public void sonPrint(){ System.out.println("son's "+t); } } public class Test { public static void main(String[] args){ Father<Integer> f=new Son<Integer>(new Integer(4)); f.fatherPrint(); Son<Integer> s=(Son<Integer>)f; s.sonPrint(); } }
Java 泛型类实现继承
最新推荐文章于 2024-06-14 00:56:49 发布