异常的小习题

来源:互联网 发布:av淘宝7m视频2017淘 编辑:程序博客网 时间:2024/06/08 09:29
public class TestException{public static void main(String args[]){TestData data=new TestData(0,2);try{int c=data.chu(data.a, data.b);if(c==0)throw new Exception("Exception");}catch (Exception x){System.out.println("出现异常:"+x);}}}class TestData{int a,b;public TestData(int x,int y){this.a=x;this.b=y;}int chu(int m,int n) throws Exception{return m/n;}}

0 0
原创粉丝点击