代码改变世界

[Android学习笔记]try-catch

2014-12-22 14:29  hellenism  阅读(313)  评论(0编辑  收藏  举报
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;
    }