[Generic interface]

package com.yjf.esupplier.common.test;

/**
 * @author shusheng
 * @description
 * @Email [email protected]
 * @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 [email protected]
 * @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 [email protected] 
 * @date 16:48 2018/12/13 
 * / 
public  class InterDemo {
     / ** 
     * generic interface: 
     * defined in the generic interface 
     * format: public interface interface name <... generic types. 1> 
     * / 
    public  static  void main (String [] args) { 

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

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

    }

}

 

Guess you like

Origin www.cnblogs.com/zuixinxian/p/11275062.html