I am working on developing a timer application in eclipse using swing tables to store data. The main issue I'm running into is that this if statement keeps returning true, even when the values in those variables are identical (as shown by the output). What could be causing this?
Here is my snippet of code:
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!");
}
}
Here is the Output:
0: Current Value: Test3 - Current PID: Test3
The value and PID are not the same for some reason!
1: Current Value: 12345 - Current PID: Test3
The value and PID are not the same for some reason!
2: Current Value: 54321 - Current PID: Test3
The value and PID are not the same for some reason!