for(int counter=0;counter<cells.size();counter++){
System.out.println("The name typed is "+name);
System.out.println("got to the loop");
String storedName=cells.get(counter).toString();
System.out.println("The cell name is "+storedName);
if(storedName==name){
System.out.println("Found it!");
break;
}else{
System.out.println("Did not find it");
}
}
输出:
输入的名称是JACK
进入循环
单元名称为JACK
没找到
我不明白为什么if语句永远不会返回true?