public class Demo4Exception {
public Demo4Exception() {
}
boolean method1() throws Exception {
boolean flag = true;
try {
flag = method2();
} catch (Exception e) {
System.out.println("method1, catch exception");
flag = false;
throw e;
} finally {
System.out.println("method1, finally; return flag = " + flag);
return flag;
}
}
boolean method2() throws Exception {
boolean flag = true;
try {
flag = method3();
if (!flag) {
return false;
}
System.out.println("method2, at the end of try");
return flag;
} catch (Exception e) {
System.out.println("method2, catch exception");
flag = false;
throw e;
} finally {
System.out.println("method2, finally; return flag = " + flag);
return flag;
}
}
boolean method3() throws Exception {
boolean flag = true;
try {
int b = 12;
int c;
for (int i = 2; i >= -2; i--) {
c = b / i;
System.out.println("i=" + i);
}
return true;
} catch (Exception e) {
System.out.println("method3, catch exception");
flag = false;
throw e;
} finally {
System.out.println("method3, finally; return flag = " + flag);
return flag;
}
}
public static void main(String[] args) {
Demo4Exception d4e = new Demo4Exception();
try {
System.out.println(d4e.method1());
详细解决方案
哪位大神有时间看一下,错误处理机制,想不通为什么这么个走法
热度:37 发布时间:2016-04-23 20:27:54.0
相关解决方案
- 书上的有关问题!错误处理
- php_study日记:错误处理
- websphere 配置库中已存在应用程序,错误处理
- Struts2 错误处理 ( jsp记录错误信息到日志 )
- [原]JavaScript学习笔记(五.错误处理)
- javascript基础(八)错误处理
- JavaScript-错误处理
- 项目-错误处理
- SQL server2005 触发器 错误处理 无法理解的现象
- QT 错误处理
- android 源码有关问题解答(错误处理)
- Android NDK开发篇(六):Java与原生代码通信(错误处理)
- PHP 错误处理 Exception 类
- php_study日记:错误处理
- 轻松了解C#错误处理 try—catch—finally
- 错误处理
- Oracle 顺序控制,错误处理,动态sql
- Oracle 学习笔记 17 - 错误处理(PL/SQL)
- PLSQL 错误处理
- oracle pl/sql 错误处理
- Mysql 错误处理
- Day24:错误处理
- PHP session 错误及mysql close 错误处理
- ORA-02019 错误处理
- CRS-0215 错误处理
- Postgresql 手动修改的自增列 错误处理