Hi I am in a real mess, trying to do a 3d array. I am only new to java so forgive me If this looks messy.I do not know how to call the methods ect. what i have to sort out is! if i enter a airport name it will display the flight No's: if i enter flight number it will display destination and flight time I was trying to ref the name of airports by int so that I can call from the rest of the array. Can any one put me on the right track please!
Hi iam sorry if i ask to much, I really do want to learn, so if anyone can give a tutorial site on 3d arrays. I will check it out as all the books i have read don't give examples on 3d. Sorry if i have come across a fool with my code as i know it is messed up and most proberly wrong in all aspects thanks if you can help, in case i am in bed when you answer as it geting late now in th UK.
OK, first "Don't Panic!" That's the best advice ever to come out of The Hitchhiker's Guide to the Galaxy. Everyone has to begin somewhere. Relax and don't worry so much about seeming a "fool". Now with that said, yes, this is a horrible attempt. You have aps, which is clearly a one-dimensional array (notice the single set of brackets in String ), but you're trying to apply multiple indices to it: aps[i]. Also, i is a static variable set outside the method, which, as you will find as you gain familiarity with programming, is something you really don't want to do. Let's just take your first goal: given the name of an airport you want to return the flights for that airport. Will there be more than one flight per airport? Probably. Will there be the same number of flights per airport? Probably not. What I'm getting at is that I don't think you want to use a multi-dimensional array at all. How about arrays stored in a hash table? Is that beyond the scope of this assignment? Try this:
Of course, that's just off the top of my head, and I haven't even compiled it, but it should work more or less. A couple final closing points about multi-dimensional arrays (for anyone left reading): 1. Multi-dimensional arrays are usually only theoretically useful. In real life, arrays or other collections of objects are more common. 2. You should make sure you understand one-dimensional arrays, before trying to wrap your mind around 2D, 3D, and nD.
Thanks Greg for your advise I am now trying with a 2d array, got my first part working calling the airport Liverpool it now displays all 3 flights. Used a counter which I read about in a book.I am stuck on second bit, will try and sort it out but I am totally confused. You will see what I mean if I can not sort it . I hope you guys won't object me coming back with a new post. Thanks again all the little problems seem major when you are just in your 1st stage of learning. Oh a special thanks to you guys who run this site for beginners, as other site's mock us for asking. What must be silly questions to them. Wish I could send a thank you card to the ranch for all the Staff and you guys and girls who give up your time to help the likes of myself. Sorry for going on to much Take care every one xxxx Lindsey