public class Text1 {
public static void main(String[] args){
List<Person<String,int>> list = new ArrayList<Person<String.int>>();/*Person用加泛型吗,要加的话,怎么写啊*/
list.add(new Person("zhangsan",34));
list.add(new Person("zhaan",36));
list.add(new Person("zhadfan",24));
list.add(new Person("zhang",56));
}
}
class Person{
private String name;
private int age;
Person(String name,int age){
this.name = name;
this.age = age;
}
public String getName(){
return name;
}
public int getAge(){
return age;
}
}
|