I need to delete an object from a vector, regardless of the position, and if the object leaves an empty space, the vector must be re-accommodated until the last empty space is left, this is what I have:
public void remove(short pos){
boolean flag = false;
for (short posRemove = pos; posRemove < listVuelos.length -1 && !flag; posRemove ++){
if(listVuelos[posRemove +1] != null){
listVuelos[posRemove] = listVuelos[posRemove + 1];
}
else {
flag = true;
listVuelos[posRemove] = null;
}
}
}