class ThreeException extends Exception { }
public class FinallyWorks {
static int count = 0;
/** Creates a new instance of FinallyWorks */
public static void main( String args[] ) {
while( true ) {
try {
if( count++ == 0 )
throw new ThreeException( );
System.out.println( "No Exception" );
} catch( ThreeException e ) {
System.err.println( "ThreeException" );
} finally{
System.err.println( "In finally clause" );
if( count == 2 ) break;
}
}
}
}
我运行的结果是:
No Exception
ThreeException
In finally clause
In finally clause
书上的结果是:
ThreeException
In finally clause
No Exception
In finally clause
PS:不管那一种结果我都看不懂 还请教
[此贴子已经被作者于2006-8-1 11:39:49编辑过]