泛型类 --代码参考:java核心技术 卷1 第十版 public class Pair<T> { private T first; private T second; //构造器 public Pair() { first = null; second = null;} public Pair(T first , T second ) {this.first = first; this.second = second;} //get方法 public T getFirst() {return…
package com.srie.testjava; import java.util.ArrayList; import java.util.List; public class TestGenerics { public static void main(String[] args) { List<Object> o = new ArrayList<Object>(); List<String> s = new ArrayList<String>();…