【发布时间】:2015-12-03 09:01:52
【问题描述】:
我想制作程序,以便当用户按下一个不在 1-10 之间的数字时,它会再次循环;它再次运行。注意:大小写介于字符串编号和默认值之间
do {
String responded;
responded = JOptionPane.showInputDialog("Do you understand do while loops?");
String number = JOptionPane.showInputDialog("Choose a number between 0 & 9 to generate \nthe corresponding word to that number or \npress 10 to exit the program");
default:
JOptionPane.showMessageDialog(null, "Please make sure the number inserted is between 0 & 10.", "Error", JOptionPane.ERROR_MESSAGE);
}
} while (responded.equalsIgnoreCase("No"));
【问题讨论】:
-
您希望编译器神奇地知道
String number应该在"0".."9"("10") 范围内。default:是来自switch结构的标签。