I explain. I have an arraylist with appointment ids 1,2,3,4,5, an acient object, and a time. I want that when I delete an appointment, for example 3, the ID of 4 becomes 3 and that of 5 becomes 4. This is what I have come up with
for (int i = 0; i < listaDoctoresG.size(); i++) {
if (listaDoctoresG.get(i).getNombreDoctor().compareToIgnoreCase(cmbDoctor.getSelectedItem().toString()) == 0) {
listaDoctoresG.get(i).getListaCitas().remove(indice);
for (int x = 0; x < listaDoctoresG.get(i).getListaCitas().size();x++) {
Doctor nD = (Doctor) listaDoctoresG.get(i);
for(int z = indice; z<=nD.getListaCitas().size(); z++ ){
int nCita = nD.getListaCitas().get(i).getNumerocita();
nCita -=1;
}
}
}
}
I know something is missing but I don't know how to do it
There are better ways to do it, but based on your question, here's an answer.
The variable numeroCitas should have a capital C. And I recommend you not to put a suffix such as Appointments or Doctor in the objects. If you are already accessing the Doctor object, you already know that Doctor.name is the name of the doctor.