Here is my problem, the if statement doesn't show the messagedialog when i don't insert anything in the inputdialog, but when i use != to compare the condition, it showup, why is this? as i know != mean not equal and == is equal
String firstName = ""; String lastName = ""; firstName = JOptionPane.showInputDialog("Please enter your first name"); if (firstName == "") { JOptionPane.showMessageDialog(null, "Don't leave it blank!"); } else { lastName = JOptionPane.showInputDialog("Please enter your last name"); } String msg = "Hello " + firstName + lastName + "!"; JOptionPane.showMessageDialog(null, msg);