Java字符串比较逻辑问题?

时间:2013-12-12 04:23:48

标签: java string apache-poi

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?

0 个答案:

没有答案