public class Student { private String name; private int age; private String sex; public Student(String name, int age, String sex) { this.name = name; this.age = age; this.sex = sex; } }public class Test { public static void main(String[] args) { Student s1 = new Student("C++", 11, "Girl"); List stuList = new ArrayList(); Map sMap = new Hashtable(); Set stuSet = new HashSet(); stuList.add(s1); stuSet.add(s1); sMap.put(1, s1); } }参考之
public class Student { private String name; private int age; private String sex; public Student(String name, int age, String sex) {
this.name = name;
this.age = age;
this.sex = sex;
}
}public class Test {
public static void main(String[] args) {
Student s1 = new Student("C++", 11, "Girl");
List stuList = new ArrayList();
Map sMap = new Hashtable();
Set stuSet = new HashSet();
stuList.add(s1);
stuSet.add(s1);
sMap.put(1, s1);
}
}参考之