代码如下:
import java.util.Scanner;
public class Exercise {
public static void main(String[] args) {
String zongbiao[][]=new String[5][5];
zongbiao[0]=new String[]{"车次", "出发站-到达站", "出发时间", "到达时间", "历时"};
zongbiao[1]=new String[]{"T40", "长春-北京", "00:12", "12:20", "12:08"};
zongbiao[2]=new String[]{"T298", "长春-北京", "00:06", "10:50", "10:44"};
zongbiao[3]=new String[]{"Z158", "长春-北京", "12:48", "21:06", "08:18"};
zongbiao[4]=new String[]{"K1084", "长春-北京", "12:39", "02:16", "13:37"};
for(int i=0;i<zongbiao.length;i++) {
for(int j=0;j<zongbiao[i].length;j++) {
System.out.print(zongbiao[i][j]+"\t");
}
System.out.println();
}
Scanner sc=new Scanner(System.in);
System.out.println("请输入要购买的车次:");
String checi=sc.next();
boolean a=checi==zongbiao[1][0];
System.out.println(a);
sc.close();
}
}
问题是从扫描器输入“T40”,结果显示输入的值不等于zhongbiao[1][0],如下图:
请问老师这个是为什么呢?谢谢!