This method basically checks whether an id is repeated and throws an error.
But it has an error: when entering a repeated id, I have more opportunities (ask for a new idea and the entry), but if I re-enter it again, it passes as true.
Does anyone know why or what mistake?
for (int i = 0; i < lista.size(); i++) {
if (lista.get(i).getidGeneral() != idGeneral) {
} else {
while (lista.get(i).getidGeneral() == idGeneral) {
try {
throw new DuplicateVehicleException("La id ya esta en uso");
} catch (DuplicateVehicleException e) {
e.printStackTrace();
}
System.out.println("Introduce una nueva id:");
idGeneral = lec.nextInt();
}
}
}