我是java的菜鸟。我正在尝试创建一个while循环,它将在每个进程后提示用户;至于他们是否希望继续。我的进步看起来像这样。
String proString,answer;
char t,f,x;
boolean exitTime;
exitTime = false;
proString = " Would You Like To Continue? \n";
while(!exitTime) {
continue;
}
answer = JOptionPane.showInputDialog(null," Would You Like To Continue? T/F ",HEADING,JOptionPane.INFORMATION_MESSAGE);
x = char.parseChar(answer);
我也尝试了以下内容但无济于事......
Prompt= JOptonPane.showInputDialog(null,proString,HEADING,JOptionPane.QUESTION_MESSAGE);
input = char.parseChar(Prompt);
if(input == "y") {
break;
}
else if(input == "n") {
}
input = char.parseChar(Prompt);
if(input != "y"||"n") {
JOptionPane.showMessageDialog(null,"Invalid Input", "Error", JOptionPane.INFORMATION_MESSAGE);
}
else {
}
我想我的问题归结为我应该使用JOptionPane.showInputDialog(...)或JOptionPane.showConfirmDialog(...)还是其他方法?请告诉我你将如何做到这一点。
答案 0 :(得分:1)
您需要的是使用do-while循环:
var mailString = EMAIL_TO.toString();
var elements = mailString.split(", ") //The separator for the mail sender
var email_to_result=true;
for (i=0;i<elements.length;i++){
if(!isMailValid( elements[i] )){
email_to_result = false;
email_to_errors = "Mail not valid"; //i've added all the wrong mail
}
}
我没有测试过它,但它应该解释你的逻辑。