1.表示类
public class Demo1<T> {
private T value;
//泛型方法
public <T> void fun(T x){
System.out.println();
}
}
2.表示接口
public interface Demo2<T> {
public T fun();
}
3.泛型通配符
public static void main(String[] args) {
List<String> strList = new ArrayList<String>();
List<Integer> intList = new ArrayList<Integer>();
strList.add("lwx");
intList.add(1);
generic(strList);
generic(intList);
}
//泛型通配符
public static void generic(List<?> data){
System.out.println(data.get(0));
}
标签:generic,void,intList,泛型,strList,public
From: https://www.cnblogs.com/lwx11111/p/17641072.html