public void testPut(){
int i=0;
Scanner reader = new Scanner(System.in);
while(i<3){
System.out.print("请输入学生ID:");
String stuId = reader.next();
Student st = students.get(stuId);
if(st==null){
System.out.print("请输入学生姓名:");
String stuName=reader.next();
students.put(stuId, new Student(stuId,stuName));
System.out.println("成功添加学生:"+students.get(stuId).name);
i++;
}else
System.out.println("学生ID已被占用!");
}
}
public void testKeySet(){
Set<String> stuIDs = students.keySet();
System.out.println("共有"+students.size()+"个学生");
for (String string : stuIDs) {
Student st = students.get(string);
System.out.println(st.id+":"+st.name);
}
}