本帖最后由 不可言 于 2014-6-20 12:46 编辑
- public static void main(String[] args) throws IOException
- {
- Scanner sc = new Scanner(System.in);
- while(true){
- try{
- int num = sc.nextInt(); //抛出异常后,就会循环执行catch里面的代码,
- break;
- }catch(InputMismatchException e){
- //当蒱获异常
- System.out.println("Error\t"+e.getMessage());
- }
- }
- }
复制代码 |
-
1.PNG
(55.59 KB, 下载次数: 9)
|