我的代码的目的是输入一个引脚,它会检查它是否正确。如果不是,问题就会循环。 出于某种原因,我的代码没有正确循环,并且很多代码都有下划线。特别是while循环本身和第二个JOptionPane
// package loop;
import javax.swing.JOptionPane;
public class loop {
public static void main(String[] args) {
int correctPin = 3333;
int count = 0;
String maybePin = JOptionPane.showInputDialog("Please enter the PIN");
int sMaybePin = Integer.parseInt(maybePin);
while(correctPin != sMaybePin);{
maybePin = JOptionPane.showInputDialog("Please enter the PIN");
count = count-1;
}
JOptionPane.showMessageDialog(null, count);
}
}
答案 0 :(得分:1)
while(correctPin != sMaybePin); <--
查看那个终止循环的;
。你需要删除它。
答案 1 :(得分:1)
您永远不会更新var uriString = string.Format("{0}/{1}", "http://hostaddress/api/ControladorServico/GetServico", nomeServico);
var result = await GetAsync<YourModel>(uriString);
,这是您要检查的变量。如果你做的话@John和@ANS建议你陷入无限循环。
答案 2 :(得分:1)
删除;在while语句之后并正确地将变量sMaybePin的值设置为输入值并且不能正常工作
public static void main(String[] args) {
int correctPin = 3333;
int count = 0;
String maybePin = JOptionPane.showInputDialog("Please enter the PIN");
int sMaybePin = Integer.parseInt(maybePin);
while(correctPin != sMaybePin){
sMaybePin = Integer.parseInt(JOptionPane.showInputDialog("Please enter the PIN"));
count = count-1;
}
JOptionPane.showMessageDialog(null, count);
}