//泛型接口:接口名<T> ,不能泛型静态常量
public interface MyGeneric<T> {
String name="张三";
T server(T t);
}
public class MyGenericImpl implements MyGeneric<String>{
@Override
public String server(String s) {
System.out.println(s);
return s;
}
}
public class MyGenericImpl2<T> implements MyGeneric<T>{
@Override
public T server(T t) {
System.out.println(t);
return t;
}
}
public class Demo01 {标签:1234,String,接口,server,泛型,MyGenericImpl2,public From: https://www.cnblogs.com/123456dh/p/17136488.html
public static void main(String[] args) {
MyGenericImpl myGeneric = new MyGenericImpl();
myGeneric.server("1234");//1234
MyGenericImpl2<String> myGenericImpl2 = new MyGenericImpl2<>();
myGenericImpl2.server("1234");//1234
}
}