package liannxi;import java.util.Scanner;public class xunhuan {public static void main(String[] orgc) { Scanner scanner = new Scanner(System.in); long a = scanner.nextLong(); int i; if(a > 1000000000) System.out.println("输入错误"); else {for(i=0;(a>0);) {a=a%10; i++; } System.out.print(i);} System.out.print(a);}}运行后出现Exception in thread "main" java.util.InputMismatchException at java.base/java.util.Scanner.throwFor(Scanner.java:939) at java.base/java.util.Scanner.next(Scanner.java:1594) at java.base/java.util.Scanner.nextLong(Scanner.java:2373) at java.base/java.util.Scanner.nextLong(Scanner.java:2328) at liannxi/liannxi.xunhuan.main(xunhuan.java:8)
1 回答
按照自己的节奏前行
TA贡献90条经验 获得超70个赞
看这个抛出的异常InputMismatchException,
你既然选择输入的数据是Long类型的,那你就只能用1,2,3,4这样的数据,不能用字符串呀,小兄弟!!!
添加回答
举报
0/150
提交
取消