I think is a bad idea to return null
values so I am looking to an alternative to this.
Here is my code:
public Flight getFlight(String id) {
for (Flight f : this.flightList ) {
if ( f.getId().equals(id))
return f;
}
return null;
}
I am looking for a certain Flight with a certain id and I want to return it.
If I return null
I have to check every time if the object I returned is null or not. And I would like to avoid this if possible.
So any suggestions are welcome.