Java 泛型接口

来源:互联网 发布:淘宝上海巨龙国际 编辑:程序博客网 时间:2024/06/05 03:33
package generic.define.Demo;public class GenericDemo5 {public static void main(String[] args) {InterImpl in =new InterImpl();in.show("abc");InterImpl2<Integer> in2=new InterImpl2<Integer>();in2.show(5);}}interface Inter<T>{ public void show(T t);}class InterImpl implements Inter<String>{public void show(String str) {System.out.println("show:"+str);}}class InterImpl2<Q> implements Inter<Q>{public void show(Q q) {System.out.println("show:"+q);}}

原创粉丝点击