我有點麻煩。問題是,當我試圖比較2個字符串(類型字符串)運算符'=='返回FALSE,但實際上字符串是平等的。 下面是帶有問題的代碼:錯誤的結果,而字符串比較
//before the following code I filled the "LinkedList <String> command" and there is
//a node with value of args[0]
String deal="";
Iterator it = commands.listIterator();
if(it.hasNext() == true)
{
if(it.next() == args[0])
{
deal += it.next();
it.hasNext();
break;
}
}
謝謝!!!
那不會編譯,你忘了「。」在next()和等於 – PsyCode 2014-09-28 20:39:24
Oooh yes!非常感謝。我怎麼能忘記...當然我們的講師告訴我們'回合等於(...) – 2014-09-28 20:40:46
@PsyCode編輯:) – Alboz 2014-09-28 20:41:21