集合框架(泛型接口)

来源:互联网 发布:lstm python实现 编辑:程序博客网 时间:2024/06/08 14:36
//泛型定义在接口上。interface Inter<T>{    void show(T t);} /* class InterImpl implements Inter<String>{    public void show(String t)    {        System.out.println("show:"+t);    }} */ class InterImpl<T> implements Inter<T>{    public void show(T t)    {        System.out.println("show:"+t);    }}class GenericDemo5{    public static void main(String[] args)    {        InterImpl<Integer> i = new InterImpl<Integer>();        i.show(4);        // InterImpl i = new InterImpl();        // i.show("haha");    }}

0 0
原创粉丝点击