0

i have some weird problems with javafx PasswordField.this is my code:

public class Form1 implements Initializable {
@FXML private PasswordField pass;
@FXML private PasswordField confpass;

@Override
public void initialize(URL arg0, ResourceBundle arg1) {
    // TODO Auto-generated method stub

}


public void btn1_onclick(ActionEvent event){
    String password = pass.getText();
    String conf = confpass.getText();
    if(conf == password)
    {
            System.out.println(":)");
    }
    else
    {
        System.out.println(password + "\t" + conf);
    }
}
}

i type same word in both PasswordField but always the if condition is false and i see two same words in console!!!

how can i fix this?

user3707208
  • 19
  • 1
  • 5

1 Answers1

2

Use equals() for comparing strings

conf.equals(password)
David Limkys
  • 4,907
  • 5
  • 26
  • 38
Dyrandz Famador
  • 4,499
  • 5
  • 25
  • 40