【泛型接口】

package com.yjf.esupplier.common.test;

/**
 * @author shusheng
 * @description
 * @Email shusheng@yiji.com
 * @date 2018/12/13 16:27
 */
public interface Inter<T> {

    public void show(T t);
}


package com.yjf.esupplier.common.test;

/**
 * @author shusheng
 * @description
 * @Email shusheng@yiji.com
 * @date 2018/12/13 16:28
 */
public class InterImpl<T> implements Inter<T> {

    @Override
    public void show(T t) {
        System.out.println(t);
    }
}


package com.yjf.esupplier.common.test;

/**
 * @author shusheng
 * @description
 * @Email shusheng@yiji.com
 * @date 2018/12/13 16:48
 */
public class InterDemo {
    /**
     * 泛型接口:
     * 把泛型定义在接口上
     * 格式:public   interface 接口名<泛型类型 1…>
     */
    public static void main(String[] args) {

        Inter<String> inter1 = new InterImpl<String>();
        inter1.show("hello");

        Inter<Integer> inter2 = new InterImpl<Integer>();
        inter2.show(30);

    }

}
终身学习者
原文地址:https://www.cnblogs.com/zuixinxian/p/11275062.html