//JDk1.5后,使用泛型来接收类中要操作的引用数据类型 //泛型类,什么时候用?当类中操作的引用数据类型不确定的时候,就使用泛型类。 class Tool<Q> { private Q q; public Tool(Q q) { this.q = q; } public Q getQ() { return q; } public void setQ(Q q) { this.q = q; } } public class Person { public static void main(String[] args) { ArrayList<Tool<Car>> list = new ArrayList<Tool<Car>>(); list.add(new Tool(new Car("1234", 234))); Tool<Car> t = new Tool<Car>(new Car("a", 31)); } }