Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Cloud/Virtualization forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

where is my silly mistake

 
Lindsey Ship
Greenhorn
Posts: 19
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi I have done what I hope is a 3 dimensional array, all I am doing is to get it to print out Liverpool and the 3 flight numbers, but i am confused over the [][][] if i have the right values as it print outs
"rubbish" flights "rubbish"
here is my code so far,
 
Lindsey Ship
Greenhorn
Posts: 19
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Sorry I should have pointed out I wanted to print all flights from Liverpool 3 in all
Thanks if you can advise
Lindsey
 
Maulin Vasavada
Ranch Hand
Posts: 1873
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi Lindsey,
u want,

hope this helps....
sorry ...u told that i shoudn't post the code in earlier post but i am unable to explain otherwise..
here u will need dynamic list (String[]) as you don't know how many flights matches your input.
now u can't do that just using String[]. so u have two options now,
1. use Vector of String (which can have dynamic elements added to it)
2. use some other structure to store dynamic listing
Vector would be little complex as you need String[] as return value of the method.
java.awt.List sounds wiered but thats what i 've used so many times as it provides flexibility. no other Java class allows us to just go on adding string in String format AND retrieve the list by just one method call, which is list.getItems() in this case.
regards
maulin.
 
Maulin Vasavada
Ranch Hand
Posts: 1873
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
and
as far as ur mistake is concerned..
u 've it at ,

result = new String[3];// not sure what figure goes here
result[i] = tdi[0][0][0];

as u said u were not sure about new String[3] statement..
u can't put it there as otherwise u'd end up creating new array for each matching Airport input and so the latest one would be returned having only one of the flight (as previous list is forgotten now when we do new String[])..
u get what i am trying to explain?
so u have to create it only ONCE and you should be able to ADD dynamically to that result as you encounter matches...
regards
maulin
 
Lindsey Ship
Greenhorn
Posts: 19
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks a million
I will log off now and try rewriting my code, it seems what we get told and what you guys do are worlds apart.
thanks again for your help and I hope the weather in your country is warmer than it is here in the UK
good night
lindsey
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic