Exception处理

记录一下异常的处理情况。下面是我使用的代码例子:

private void testException(){
        try
        {
            //throw new Exception();
            return;
        } catch (Exception e)
        {
            Log.d(TAG, "catch");
        } finally
        {
            Log.d(TAG, "finally");
        }
    }

case1:

    try代码:throw new Exception();
    打印语句:“catch”  “finally”

case2:

    try  代码: 空
    打印语句: “finally” 
    结      论: try代码正常结束,finally语句块被调用

case3:

    try  代码: return;
    打印语句:“finally” 
    结      论: try代码return,finally语句块被调用

原文地址:https://www.cnblogs.com/hsji/p/5116920.html