日期:2014-05-20 浏览次数:20790 次
package com; import java.util.Scanner; public class Test1 { public static void main(String[] args) { Scanner sc = new Scanner(System.in); while (true) { try { int score = 0; score = sc.nextInt(); } catch (Exception e) { System.out.println("输入的不是一个整数"); continue; } } } }
import java.util.Scanner; public class Test1 { public static void main(String[] args) { Scanner sc = new Scanner(System.in); while (true) { try { int score = 0; score = sc.nextInt(); } catch (Exception e) { System.out.println("输入的不是一个整数"); String temp = sc.next();//加上这句,让把输入的非数字读进去 continue; } } } }