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
}
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
}
将值传递给earliestDepart
方法。
public void earliestDepart(List<Airline> infoList){...}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.