0

I have a class named AirMain where I took in inputs from the user of airline information. I have another class named Airline where constructors are created to store the user input as as Airline object which then store into ArrayList named "info".

I have another ArrayList named "query" storing objects from Airline class but different parameter from the "info" ArrayList.

When I tried to pass both of these ArrayList to another class method (named earliestDepart() in Airline class), I receive error "Cannot find symbol; location: class Object". It is quite a lengthy code, so please see below for a snapshot of the passing to other method of another class and the point where error happens.

Please advise me how do I pass Arraylist containing of objects to another class for process. Thanks in advance!

Code in AirMain Class

ArrayList <Airline> info = new ArrayList<Airline>();
ArrayList <Airline> query = new ArrayList<Airline>();
Airline createAirline = new Airline (fromCity, toCity, departTime, arriveTime, cost);
info.add(createAirline);
Airline createQuery = new Airline(type, fromCity, toCity);
query.add(createQuery);
if (query.get(i).getType() == 1) { query.get(i).earliestDepart(info);  }//end of if type 1

Code in Airline Class

public void earliestDepart(ArrayList info){
String retrieve = info.get(i).getFromCity();//error kicks into this statement 
}
2
  • What is i? I don't see it defined anywhere. Commented Feb 10, 2013 at 16:29
  • The "i" is define in the "for" loop. for (int i=0; i<numOp; i++){ //codes } Commented Feb 10, 2013 at 16:36

2 Answers 2

1

You need to modify the info argument in your earliestDepart() method like this:

public void earliestDepart(List<Airline> info){
String retrieve = info.get(i).getFromCity();//error kicks into this statement 
}
Sign up to request clarification or add additional context in comments.

Comments

0

Pass by value to earliestDepart method.

public void earliestDepart(List<Airline> infoList){...}

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.