假设我有一个(非常简单)这样的递归方法:
public static void myMeth(int n)
{
// do something
// now execute the recursive call
if (n < 0) return;
else if ( n == SOME_CONST ) throw new UnsupportedOperationException();
else myMeth(n - 1);
}
(第二个条件n == SOME_CONST
只是为了说明有时会发生异常,有时不会发生异常)。
假设我调用myMeth(10)
,并且在几次递归调用(比如 )之后确实发生了异常SOME_CONST == 5
。
有什么技巧可以try-catch
让我回到第一帧myMeth
吗?