(pass[i]!= null) && (pass[i].getName()!= "nullnull") <–returning true when I debug it even though the value of pass[i].getName() == "nullnull" when I check it using the Expressions window in eclipse while debugging
im using the input dialog box to input two names
String firstName = (String)JOptionPane.showInputDialog("Enter First Name");
String lastName = (String)JOptionPane.showInputDialog("Enter Last Name");
and returning
public String getName()
{
return FirstName + LastName;
}
You have two different strings with the same value, but you’re comparing them by reference.
You need to compare them by value by writing
"nullnull".equals(pass[i].getName()).The reversed order will work even if
getName()returnsnull.