可以帮忙看看这是哪有问题吗?不管在不在数组内都显示不在数组。
import java.util.Scanner;
public class StudentSearch {
public static void main(String[] args) {
Scanner name = new Scanner(System.in);
System.out.println("请输入要查找的学生姓名:");
String n = name.next();
String [] room104 = new String[6];
room104[0] = "zjy";
room104[1] = "zll";
room104[2] = "wzz";
room104[3] = "jfmx";
room104[4] = "lzk";
room104[5] = "zyl";
for (int i = 0;i < room104.length;i++) {
if(n == room104[i]) {
System.out.println("该学生在104宿舍内。");
}else {
System.out.println("该学生不在104宿舍内。");}
}
name.close();
}
}