Witam. Napisałem funkcję do usunięcia danego studenta z listy. Niestety wyrzuca wyjątek. Poniżej screen oraz kod.
//metoda
public void usunStudenta(int ile)
{
while (itStudent.hasNext()) {
Student student = itStudent.next();
if(student.getNrAlbumu()== ile)
itStudent.remove();
}
}
//użycie w main
System.out.println("Usun studenta o id: ");
nrAlbumu = in.nextInt();
studenci.usunStudenta(nrAlbumu);
- Blad.png (31 KB) - ściągnięć: 61
kolekcjaStudentów.removeIf(student -> student.getNrAlbumu() == ile );
Shalom