public class test {
/**
* @param args
*/
public static void main(String[] args) {
// TODO Auto-generated method stub
try
{
test1();
System.out.println("after");
}
catch(Exception e)
{
System.out.println("waibu");
}
finally
{
System.out.println("innerfinally");
}
}
public static void test1()
{
try
{
int i=1/0;
}catch(Exception e)
{
System.out.println("inner");
}
finally
{
System.out.println("innerfinally");
}
//int i=1/0;
}
}
输出结果
inner
innerfinally
after
innerfinally
结论:内层catch捕获了,外侧catch就不捕获了。否则外侧捕获