public class Demo2 {
public static void main(String[] args) {
String[] chinese = {"零","一","二","三","四","五","六","七","八","九"};
Scanner sc = new Scanner(System.in);
String temp ="";//临时存取键盘输入的
while (true) {
System.out.println("请输入一个大于-1且小于1000的正整数");
temp = sc.nextLine();
try {
int num = Integer.parseInt(temp);
//print(num,chinese);
break;
} catch (Exception e) {
System.out.println("输入错误");
}
}
} |