データを格納するためにスイング テーブルを使用して、Eclipse でタイマー アプリケーションの開発に取り組んでいます。私が直面している主な問題は、これらの変数の値が同一であっても (出力に示されているように)、この if ステートメントが true を返し続けることです。何が原因でしょうか?
コードのスニペットは次のとおりです。
String currentPID = lblCurrentPID.getText();
for (int i = 0; i < tableActive.getRowCount(); i++) {
String currentValue = (String) tableActive.getValueAt(i, 2);
System.out.println(i + ": Current Value: " + currentValue + " - Current PID: "+ currentPID);
if (currentPID != currentValue) {
System.out.println("The value and PID are not the same for some reason!");
}
else {
tableActive.setValueAt(ts1.getOverallTotalTime(), i, 3);
System.out.println(i + ": Row Was Changed!");
}
}
出力は次のとおりです。
0: 現在の値: Test3 - 現在の PID: Test3
値と PID が何らかの理由で一致しません。
1: 現在の値: 12345 - 現在の PID: Test3
値と PID が何らかの理由で一致しません。
2: 現在の値: 54321 - 現在の PID: Test3
値と PID が何らかの理由で一致しません。