I have created an array of objects (object representing a flight), and i'm trying to create a method to remove a specific object from that array, without changing it's length. I have written the following method :
public boolean removeFlight (Flight f) {
for (int i = 0 ; i < _noOfFlights ; i++) {
if (_flightsSchedule[i].equals(f)) {
_flightsSchedule[i] = _flightsSchedule[(i+1)];
_noOfFlights--;
return true;
}
}
return false;
}
_noOfFlights represents the number of object currently in the array. For some reason it returns "false" when given an object that was added to the array.