You could use an ArrayList. Your addFlight method would then create a Flight object with their data and add it to the list, and you're sorted.
EDIT: sorted as in "you're all set", not as in your data is now in order.
jon.kiparsky
Posting Virtuoso
1,849 posts since Jun 2010
Reputation Points: 383
Solved Threads: 187
Looping through the members of an ArrayList is easy enough:
for (Flight f: flightsList)
{
// do what you want to do with each flight: f will take the value of each one in turn
}
Quuba's solution can work, but arrays are fixed, so you'd have to put in some provision for resizing. That's not very difficult, but the work has been done for you if you use an ArrayList, and you can be pretty sure that the library methods will do it better than you will.
jon.kiparsky
Posting Virtuoso
1,849 posts since Jun 2010
Reputation Points: 383
Solved Threads: 187