public static void deleteStudent(ArrayList<Student> arry) {
Scanner sc = new Scanner(System.in);
System.out.println("请输入要删除的学生的学号:");
String sid = sc.nextLine();
int index = -1;
for (int i = 0; i < arry.size(); i++) {
Student s = arry.get(i);
if (s.getSid().equals(sid)) {
index = i;
break;
}
}
if (index == -1) {
System.out.println("该信息不存在,请重新输入");
} else
System.out.println("删除成功");
} |
|