【每日日报】第二十八天

1 8.5上机练习

 1 package BaoCuo;
 2 
 3 public class ZiDingYi {
 4     public static void main(String[] args){
 5         ZiDingYi z=new ZiDingYi();
 6         try{
 7             z.add(3,2);
 8         }catch(MyException e){
 9             e.printStackTrace();
10         }
11     }
12   private void add(int a,int b) throws MyException{
13       if(a==b){
14           throw new MyException("输入两个数相等");
15       }
16       if(a!=b){
17           throw new MyException();
18       }
19   }
20 }
21 
22 class MyException extends Exception{
23     public MyException(String msg){
24         super(msg);
25     }
26     public MyException(){
27         super();
28     }
29     public MyException(String message,Throwable cause){
30         super(message,cause);
31     }
32     public MyException(Throwable cause){
33         super(cause);
34     }
35 }
 

2 没遇到什么问题

3 明天继续看书

原文地址:https://www.cnblogs.com/linmob/p/13430465.html