如果 else 分支从未使用过

我正在使用 if else 并突然写下一些代码, else 表示从未使用过该分支......但它应该可以工作。


声明看起来像这样


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");

}


UYOU
浏览 134回答 1
1回答

陪伴而非守候

检查JOptionPane.showConfirmDialog响应并与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");}
打开App,查看更多内容
随时随地看视频慕课网APP

相关分类

Java