23,404
社区成员
发帖
与我相关
我的任务
分享
Scanner sc = new Scanner(System.in);
String s = sc.nextLine();
try {
//int x = Integer.parseInt(s);
long x = Long.parseLong(s);
s = x + "";
if (s.length()!=13)
System.out.println("数字长度不是13");
else
System.out.println("格式正确");
} catch (NumberFormatException e) {
System.out.println("输入字符串格式不对");
}
Scanner sc = new Scanner(System.in);
String s = sc.nextLine();
try {
int x = Integer.parseInt(s);
s = x + "";
if (s.length()!=13)
System.out.println("数字长度不是13");
else
System.out.println("格式正确");
} catch (NumberFormatException e) {
System.out.println("输入字符串格式不对");
}