codecamp

Exception

Exception 所有方法都默认抛出可以抛出RuntimeException。 1.异常的分类:

1.受检异常:是指程序中必须接受检查和处理的异常,由Exception 类表示。
2.非受检异常:是程序中可以不接受检查和处理,或致命性错误异常,由RuntimeException类或Error类表示。

2.有三种处理异常的方式:

1.捕获(使用try-catch-finally语句)
2.直接抛出(方法声明throws)
3.捕获再抛出(一般为将受检异常转化为非受检异常,以便解决当前类抛出的异常不在父类的异常范围之内的问题。)

3.子类的异常 是 父类的异常 的子类: 记忆方式:下级出错要在上级的处理能力范围之内。

class A {
    public void print() throws Exception {}
}
class B extends A{
    public void print() throws IOException {}
}
E
extends
温馨提示
下载编程狮App,免费阅读超1000+编程语言教程
取消
确定
目录

关闭

MIP.setData({ 'pageTheme' : getCookie('pageTheme') || {'day':true, 'night':false}, 'pageFontSize' : getCookie('pageFontSize') || 20 }); MIP.watch('pageTheme', function(newValue){ setCookie('pageTheme', JSON.stringify(newValue)) }); MIP.watch('pageFontSize', function(newValue){ setCookie('pageFontSize', newValue) }); function setCookie(name, value){ var days = 1; var exp = new Date(); exp.setTime(exp.getTime() + days*24*60*60*1000); document.cookie = name + '=' + value + ';expires=' + exp.toUTCString(); } function getCookie(name){ var reg = new RegExp('(^| )' + name + '=([^;]*)(;|$)'); return document.cookie.match(reg) ? JSON.parse(document.cookie.match(reg)[2]) : null; }