// String str = String.valueOf(jComboBox7.getSelectedItem());
String str = (String) jComboBox7.getSelectedItem();
String str1 = "YES";
System.out.println("str "+str);
System.out.println("str1 "+str1);
// if(String.valueOf(jComboBox7.getSelectedItem())=="YES")
if(str.equals(str1)) {
System.out.println("equal");
jTextField15.setText("NA");
} else {
System.out.println("not equal");
}
输出:
str YES
str1 YES
not equal
输出应该相等,但显示不相等。