With reference to the similar question. How to dynamically create Lists in java? I have quite a similar problem to the person asked.
In my project I have airplanes, airports and passengers for PNR record
The passenger destination airport is exported from database, but then I have to add it to a List of destination with name,airplanes.
So the database will contain like
A380, JFK, PersonA
A380, JFK, PersonB
A330, LHR, PersonC
My plan is to create the list of airport dynamically from the database and add those passenger with the same destination to it.
So currently I have peronsA and personB with JFK they will be in the same list. While in the LHR list only personC will be in LHR list, there will be hundreds of thousand record of such and hundreds of airport list to create, so I have to create such list dynamically.
But question is how do I determine if the the airport(JFK) list already exists and not create another list for that particular airport? Or is there another way to store information?
Pseudo code:
while (dbrecord =true){
if(passenger.destination == "JFK"){
List<passenger> JFK(dynamic)= new ArrayList<passenger>();
JFK(dynamic).add(passenger)
}
if(passenger.destination == "JFK")it can be replaced byequals()