public class Person<T>{
private T date;
public T getData() {
return data;
}
public void setData(T data) {
this.data = data;
}
}
泛型方法
public static <T> void main(T t){
}
泛型接口
public interface Test()<T>{
T print();
}
//指定类型
public class Main implements Test<String>{
private String date;
@Override
public String print(){
return date;
}
}
//不指定类型
public class Main implements Test<T>{
private T date;
@Override
public T print(){
return date;
}
}