[Android学习笔记]try-catch

private boolean test() {
        boolean result = true;
        String str = null;
        try {
            Log.d("test","出现异常之前");
            int length = str.length();
            Log.d("test","出现异常之后");
        } catch (Exception e) {
            result = true;
            Log.d("test","catch块");
        }
        result = false;
        Log.d("test","catch执行完成之后");
        return result;
    }

[Android学习笔记]try-catch_第1张图片

你可能感兴趣的:(Android学习)