Scanner sc = new Scanner(System.in);标签:shu,int,str1,System,类似,算法,str,parseInt,out From: https://www.cnblogs.com/liuxuefeng/p/17724255.html
String str = "";
while(true){
System.out.println("请输入");
String str1 = sc.nextLine();
if(str1.length() < 1 || str1.length() > 10 || str1.charAt(0) == '0') {
System.out.println("格式有误");
continue;
}
str = str1;
break;
}
int shu = 0;
for (int i = 0; i < str.length(); i++) {
int ge = str.charAt(i) - 48;
shu = shu * 10 + ge;
}
System.out.println(shu);