find函数的if()语句为什么进不去?
以下为主代码
package AircraftManagement;
import java.sql.SQLOutput;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
ArrayList<Route> rs=new ArrayList<>(); //存所有航班的列表
boolean b=true;
Scanner scan =new Scanner(System.in);
while(b){
System.out.println("输入数字执行操作:");
System.out.println("1.录入航班信息\t2.查询航班\n0.退出系统");
int a=scan.nextInt();
switch(a){
case 1:
addRoute(rs);break;
case 2:
System.out.println("输入终点站名称:");
Scanner s=new Scanner(System.in);
String str=s.next();
find(rs,str);
break;
case 0:
b=false;break;
}
}
}
public static void addRoute(ArrayList<Route> rs){//录入
System.out.println("请按以下的顺序录入航班信息:\n终点站、航班号、飞机号、起飞时间、 头等舱容量、商务舱容量、经济舱容量");
Scanner scan=new Scanner(System.in);
String T=scan.next();
String H=scan.next();
String F=scan.next();
String ST=scan.next();
int C1=scan.nextInt();
int C2=scan.nextInt();
int C3=scan.nextInt();
Route r=new Route(T,H,F,ST,C1,C2,C3);
r.setRemainderTickets1(C1);
r.setRT2(C2);
r.setRT3(C3);
rs.add(r);
}
public static void find(ArrayList<Route> rs,String terminus){
Iterator it=rs.iterator();
while(it.hasNext()){
Route o=(Route)it.next();
if(o.getTerminus()==terminus){
System.out.println("航班号:"+o.getHnum()+"\n飞机号:"+o.getFnum()+"\n起飞时间:"+o.getStartTime()+"\n头等舱余票量:"
+o.getRemainderTickets1()+"\n商务舱余票量:"+o.getRT2()+"\n经济舱余票量:"+o.getRT3());
}
System.out.println("测试用:o.getTerminus()="+o.getTerminus());
System.out.println("测试用:terminus="+terminus);
}
}
}
以下为航班类
package AircraftManagement;
import java.util.ArrayList;
import java.util.List;
/*
航班类
*/
class Route {
private String Terminus; //终点站
private String Hnum; //航班号
private String Fnum; /{号
private String StartTime; //起飞时间
private int Capacity1; //头等舱容量
private int C2; //商务舱容量
private int C3; //经济舱容量
private int RemainderTickets1; //头等舱余票量
private int RT2; //商务舱余票量
private int RT3; //经济舱余票量
List<Customer> l=new ArrayList<Customer>(); //已订票的客户名单
List<Customer> t=new ArrayList<Customer>(); //替补排队客户名单
public Route(){}
public Route(String terminus, String hnum, String fnum, String startTime, int capacity1, int c2, int c3) {
Terminus = terminus;
Hnum = hnum;
Fnum = fnum;
StartTime = startTime;
Capacity1 = capacity1;
C2 = c2;
C3 = c3;
}
public String getTerminus() { return Terminus; }
public String getHnum() { return Hnum; }
public String getFnum() { return Fnum; }
public String getStartTime() { return StartTime; }
public int getCapacity1() { return Capacity1; }
public int getC2() { return C2; }
public int getC3() { return C3; }
public int getRemainderTickets1() { return RemainderTickets1; }
public int getRT2() { return RT2; }
public int getRT3() { return RT3; }
public void setTerminus(String terminus) { Terminus = terminus; }
public void setHnum(String hnum) { Hnum = hnum; }
public void setFnum(String fnum) { Fnum = fnum; }
public void setStartTime(String startTime) { StartTime = startTime; }
public void setCapacity1(int capacity) { Capacity1 = capacity; }
public void setC2(int c2) { C2 = c2; }
public void setC3(int c3) { C3 = c3; }
public void setRemainderTickets1(int remainderTickets1) { RemainderTickets1 = remainderTickets1; }
public void setRT2(int RT2) { this.RT2 = RT2; }
public void setRT3(int RT3) { this.RT3 = RT3; }
}
if判断不成立?if判断不成立?if判断不成立?