视频
笔记
3.6.查看功能_findAllStudent
private void findAllStudent() { System.out.println("学号"+"\t"+"姓名"+"\t"+"年龄"+"\t"+"性别"); /* 排序是为了防止:删除完之后再重新添加之前删除的序号对应的学生而发生乱序的情况 */ for (int j = 0; j < count-1; j++) { for (int i = 0; i < count-1-j; i++) { if (students[i].getId()>students[i+1].getId()){ Student temp = students[i]; students[i] = students[i+1]; students[i+1] = temp; } } } //如果count为0(证明没有添加过学生),证明没有学生 if (count==0){ System.out.println("对不起,现在班级没有学生,待开班........."); }else{ //我们应该是添加了多少个学生,count就是几,就应该遍历几次 for (int i = 0; i < count; i++) { System.out.println(students[i].getId()+"\t"+students[i].getName()+"\t"+students[i].getAge()+"\t"+students[i].getSex()); } } }