try{
// some statements
}catch(Exception e){
// 让finally块不执行
// 请键入语句.
//
}finally{
System.out.println("finally");
}
// some statements
}catch(Exception e){
// 让finally块不执行
// 请键入语句.
//
}finally{
System.out.println("finally");
}
try{
System.out.println("try block");
throw new Exception("测试");
}catch(Exception e){
System.out.println(e.toString());
System.exit(0);
}finally{
System.out.println("1111");
}
try{
// do something
}catch(Exception e){
// error handler
caught = true;
}finally{
if( ! caught ){
// do something
}
}
LZ不必纠缠于这个问题了,基本没有意义。。
// some statements
}catch(Exception e){
// 让finally块不执行
System.exit(0);
//
}finally{
System.out.println("finally");
}让其退出程序不就行了。
加上了还不要人家执行,
真是六个指指头挠痒,多此一举
try{
// some statements
}catch(Exception e){
try{
}catch(Exception e){
}
finally{
System.out.println("finally");
}
或者
while(true);
//
}catch(Exception e){
System.exit(0);
}finally{
System.out.println("1111");
}
话也不要说的太绝了: try {
throw new RuntimeException();
} catch (Exception e) {
for(;;); // 山无棱...
} finally {
System.out.println("finally");
}
throw new RuntimeException();
} catch (Exception e) {
Thread.currentThread().suspend(); // Deprecated, but it does work.
} finally {
System.out.println("finally");
}
throw new RuntimeException();
} catch (Exception e) {
Object lock = new Object();
synchronized (lock) {
lock.wait();
}
} finally {
System.out.println("finally");
}