finally block and Exception handling -- Java
来源:互联网 发布:no sleep for mac下载 编辑:程序博客网 时间:2024/05/29 13:18
The finally block, if used, is placed after a try block and the catch blocks that follow it. The finally block contains code that will be run whether or not an exception is thrown in a try block.
//Syntax of exception handlingpublic void someMethod(){ Try{ // some code } Catch(Exception x){ //throw exception code } Catch(Exception y){ // throw exception code } Finally{ // this code will be executed whether or not an exception is thrown or caught. }}
Three possibilities when the code in the try - catch - finally blocks is run:
1. The try block runs to the end and no exception is thrown. In this case, the finally block is executed after the try block.
2. An exception is thrown in the try block and is caught in on of the catch blocks positioned after the try block. In this case, the finally block is executed after the catch block is executed.
3. An exception is thrown in the try block and there is no matching catch block in the method to catch the exception. In this case, the method invocation ends and the exception object is thrown to the enclosing method. However, the finally block is executed before the method ends.
- finally block and Exception handling -- Java
- [转载] Basic try-catch-finally Exception Handling in Java
- Logging & Exception Handling Application Block
- Java exception handling
- Exception handling in java
- Exception Handling in Java
- Difference between throw and throws in Exception handling - Java Example
- Java Exception Handling Tutorial with Examples and Best Practices
- Java - Difference between throw and throws in Exception handling
- 30 Java Exception Handling Interview Questions And Answers
- x86 exception and interrupt handling
- Exception Handling Application Block (5)详细解
- Java and event handling
- Exception Handling and Crash Reporting - Part 1
- Exception Handling - Do's and Dont's
- Lab 7: Logging and Exception Handling
- C#note 05: Errors and Exception Handling
- Exception handling in X++ and C#
- 第7周作业1-循环大战
- Create environment for DVWA on Windows7
- java数组
- cocos2d-x 3.0rc2版发布了
- 第7周作业1-循环大战for
- finally block and Exception handling -- Java
- 利用Appserv + DZ搭建一个论坛模板
- 以自己的亲身经历献给那些在沈阳找工作看见沈阳深讯招聘信息的程序员们
- Cracking The Coding Interview5.1
- 第7周作业1-循环大战
- c++ 调用 python
- MYSQL用户权限管理(Grant,Revoke)
- POJ 3693 Maximum repetitionsubstring(后缀数组:循环子串)
- win8系统打不来chm文档文件的解决方案