首页 > 其他 > 详细

异常处理

时间:2016-05-23 19:17:59      阅读:225      评论:0      收藏:0      [点我收藏+]

public class Demo7

{

public static void main(String[] args)

{

try{

int c=sum(3,4); //throw new Exception(int c=sum(3,4);System.out.println();

System.out.println(c);

}catch(Exception e){

System.out.println(e);

}


}

public static int sum (int a,int b)throws Exception{

return a/ b;

}

}

以上程序主要是为了说明try{}Exception(){}的使用

throws Exception主要应用在方法上


异常处理

原文:http://11588233.blog.51cto.com/11578233/1782215

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!