异常


异常的使用和try{}catch{}finally{}

 1      int a = 0;
 2         try{
 3             Exception exception = new Exception("不能既填行又填列");
 4             throw exception;
 5         }catch (Exception e){
 6             if(e.getMessage().equals("不能既填行又填列")){
 7                 a = 1;
 8                 System.out.println("catch输出:"+ a);
 9             }
10         }finally {
11             a = 2;
12             System.out.println("finally输出:"+ a);
13         }