这个是代码
public class ExceptionRe {
public static int func1(int n)
{System.out.println("func1");
return n;
}
public static int func2(int n)
{
System.out.println("func2");
return n+1;
}
public static void func3(int n)
{
System.out.println("func3");
++n;
}
public static int test1(int n)//test1
{
try{
return func1(n);
}
finally{
func3(n);
}
}
public static int test2(int n)//test2
{
try{
return func1(n);
}
finally
{
return func2(n);
}
}
public static void main(String[] args) throws Exception {
// TODO Auto-generated method stub
int n=1;
System.out.println(test1(n));
System.out.println(test2(n));
}
} |