-2

I'm using if else and writing down some codes suddenly happens the else said the branch is never used... but it should work.

The statement looks like this

JOptionPane.showConfirmDialog(null,full_name+"\n"+number_age+"\n"+gender+"\n"+address+
                 "\n"+birthday+"\n"+cell_no,"CHECK INFORMATION!",JOptionPane.YES_NO_OPTION);
if(true){
    JOptionPane.showMessageDialog(null,"Thank you for Entering");
}else{
    JOptionPane.showMessageDialog(null,"Please Retry");
}
Jonathan Gagne
  • 4,241
  • 5
  • 18
  • 30

1 Answers1

1

Check JOptionPane.showConfirmDialog response and compare with JOptionPane.YES_NO_OPTION:

int answer = JOptionPane.showConfirmDialog(null,full_name+"\n"+number_age+"\n"+gender+"\n"+address+
                 "\n"+birthday+"\n"+cell_no,"CHECK INFORMATION!",JOptionPane.YES_NO_OPTION);
if (JOptionPane.YES_OPTION == answer)) {
    JOptionPane.showMessageDialog(null,"Thank you for Entering");
} else {
    JOptionPane.showMessageDialog(null,"Please Retry");
}
Ori Marko
  • 56,308
  • 23
  • 131
  • 233