解决方案 »

  1.   

    if (iterator.hasNext()) {
    换为 while(iterator.hasNext())
    if 只走一次,while会一直循环下去的
      

  2.   

    +1 boolean flag = false;//flag用来标记是否找到对应的学生
    while (iterator.hasNext()) {
    Student type = (Student) iterator.next();System.out.println(type.num.length());
    if (s .equals(type.num)) {set.remove(type);
    new Append().add(set);
    System.out.println(type);
    System.out.println("Has deletede it");
    flag =true;//找到学生改变flag
    }
    }
    if(!flag){
    System.out.println("No this one");
    }
      

  3.   

    if (iterator.hasNext()) {
    换为 while(iterator.hasNext())
    if 只走一次,while会一直循环下去的