File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Beginning Java and the fly likes where am i calling method in wrong ?? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "where am i calling method in wrong ??" Watch "where am i calling method in wrong ??" New topic
Author

where am i calling method in wrong ??

Lindsey Ship
Greenhorn

Joined: Feb 07, 2003
Posts: 19
Hi every one, yet again
First I must state I must use this type of array
The program works for the first stage ie. when i type a name of a airport in. It displays all the flights.(great that took me 4 nights to work out)
The program then ask for a flight number.
It is supposed to display the destination and flight time.
But it is now I get array out of bounds ???
also in compiling I get this, which i thought i would need to display fight time.

Error message =
\java\AirLine1.java:119: cannot resolve symbol
symbol : variable k
location: class AirLine
System.out.print(" Destination " +info1[ j ] +" Flight Time"+ info1[k]+"\n " );
^
1 error
Process completed.

Can any one tell me where I am going wrong in my code please. I have posted the full code so far but I can't get pass this problem.

Thanks if you can advise a learner to java
Lindsey
William Barnes
Ranch Hand

Joined: Mar 16, 2001
Posts: 984

I am just going to let you know what I see, I don't know if this willl answer your original question:

This code says you have three loops, one inside the other. You are not placing curly brackets after each 'for' so the code is hard to read. Inside of all these loops you only use 'j'. What are the other loops suppose to be doing for you? Except creating lots of confusion?


Please ignore post, I have no idea what I am talking about.
William Barnes
Ranch Hand

Joined: Mar 16, 2001
Posts: 984


Where is 'k' coming from? I don't see it declared anywhere.
William Barnes
Ranch Hand

Joined: Mar 16, 2001
Posts: 984


It looks like you are trying to load 3d data into a 2d array.
[ February 13, 2003: Message edited by: William Barnes ]
William Barnes
Ranch Hand

Joined: Mar 16, 2001
Posts: 984


You can't use this test for a multidiamentional array. Well you can but it will tell you to total of all the elements. So you can't use it this way:

for(int i = 0; i < tdi.length; i++)

and assume that 'i' will stay in bounds for the first diamention of the array.
William Barnes
Ranch Hand

Joined: Mar 16, 2001
Posts: 984

Ok I have a suggestion. You don't see to know how to use multi-diamentional arrays. So trying to write code which will search though them is going to be a bit difficult. (Actually impossible.)
I would suggest that you load the array and print it out, in the exact same format which it is loaded - a table.
When you are able to do that than you will understand how the data is stored, and how to access it. Only than do you want to start thinking about how to search through it.
Lindsey Ship
Greenhorn

Joined: Feb 07, 2003
Posts: 19
Thanks for your advise, as you can guess I am still lost with java , if i take out the j and k which i tried before i posted will i be able to call the data then or am i going down the wrong path. As my first method works great, do i have to do 2 more methods one for calling destination and one for time.
oh am i laying my code out in the right order the way i placing methods and the rest out.
thanks again
Lindsey
Lindsey Ship
Greenhorn

Joined: Feb 07, 2003
Posts: 19
Hi again I have took out j and k
ist method works okay ie.
if I enter Liverpool it displays all flights
Then I ask for a flight number ie 553 I
expected it to print out "Frankfurt" as that
flight leaves liverpool to "Frankfurt"
but
what the 2nd method is doing is printing out
all destinations with 553.
Can you give us a tip on this please
Lindsey
Junilu Lacar
Bartender

Joined: Feb 26, 2001
Posts: 4442
    
    5

All right, let's back up here a minute and see if we can try to get your requirements straight. From what I can see from the code you've given this is what is supposed to happen:
  • You start with a given set of data about flights: Airport, Flight#, Destination, Flight Time. This data should be contained in an array of some sort (more on this below)
  • User is prompted for a name of an airport
  • System displays a list of flight numbers originating from that airport or an error message if the airport could not be found
  • User is prompted for a flight number
  • System displays the destination and the flight time or an error message if the flight number could not be found.


  • Is this correct? Also, you have been asking about three dimensional arrays. Your code, however, only has a 2-dimensional array. How exactly should the data be organized?


    Junilu - [How to Ask Questions] [How to Answer Questions]
    William Barnes
    Ranch Hand

    Joined: Mar 16, 2001
    Posts: 984

    > am i laying my code out in the right order the way i placing methods and the rest out
    That is fine.
    Please ignore my earlyer post about 3d arrays. I was confused.
    > what the 2nd method is doing is printing out all destinations with 553.
    Please post the latest version of this method.
    Lindsey Ship
    Greenhorn

    Joined: Feb 07, 2003
    Posts: 19
    HI Junilu
    Thanks for your help, you was spot on with what my code has to do.
    But after a full week of late nights I relised the layout of what they want is wrong.I am not suprised if you heard my screams their in the USA.
    I have made a good start on my new version about a 3rd way through it. But bang I have Hit a brick wall again. Now i feel i can not come back to you guys as you have already been decent to give up your time so far.
    Thanks again and I wish all of you on your ranch
    the best of luck and good health
    Lindsey
    Thomas Paul
    mister krabs
    Ranch Hand

    Joined: May 05, 2000
    Posts: 13974
    Originally posted by Lindsey Ship:
    Now i feel i can not come back to you guys as you have already been decent to give up your time so far.
    Don't be silly! Most of us live to solve other people's problems. (That way we can avoid working on our own. )


    Associate Instructor - Hofstra University
    Amazon Top 750 reviewer - Blog - Unresolved References - Book Review Blog
    William Barnes
    Ranch Hand

    Joined: Mar 16, 2001
    Posts: 984

    > Now i feel i can not come back to you guys as you have already been decent to give up your time so far.
    Don't be silly. We love criticizing your code, ... I mean helping you out. We don't show up unless we have time. So please post back with the new code (but start a new thread). Thanks.
     
     
    subject: where am i calling method in wrong ??
     
    Similar Threads
    don't know how to call method in my new version of code
    where is my silly mistake
    Java Webservice problem (Array)
    I'm lost on how to do and call 3d array
    which of these 2 arrays is right