[读书笔记]about Exceptions

 

Ø        Exceptions identify errors that arise in your program.
Ø        Exceptions are objects of subclasses of the Throwable class.
Ø        Java includes a set of standard exceptions that may be thrown automatically, as a result of errors in your code, or may be thrown by methods in the standard classes in Java.
Ø        If a method throws exceptions that aren’t caught, and aren’t represented by subclasses of the Error class or by subclasses of the RuntimeException class, then you must identify the exception classes in a throws clause in the method definition.(也就是说,Error和RuntimeException的子类是不需要捕获的;而其它种类的Exception被编译器强制要求捕获处理。)
Ø        If you want to handle an exception in a method, you must place the code that may generate the exception in a try block. A method may have several try blocks.
Ø        Exception handling code is placed in a catch block that immediately follows the try block that contains the code that can throw the exception. A try block can have multiple catch blocks that each deals with a different type of exception.
Ø        A finally block is used to contain code that must be executed after the execution of a try block, regardless of how the try block execution ends. A finally block will always be executed before execution of the method ends.
Ø        You can throw an exception by using a throw statement. You can throw an exception anywhere in a method. You can also rethrow an existing exception in a catch block to pass it to the calling method.
Ø        You can define your own exception classes that, in general, should be derived from the class Exception.
 
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值