View Code
1 class Math{
2 public int div(int i,int j) throws Exception{
3 int t=i/j;
4 return t;
5 }
6 }
7 public class ThrowsDemo {
8 public static void main(String args[]) throws Exception{
9 Math m=new Math();
10 System.out.println("出发操作:"+m.div(10,2));
11 }
12 }
主方法使用throws关键字