java深刻理解try-catch....?
PHPz
PHPz 2017-04-17 17:49:33
0
1
489

我for循环里面套一个try....如果某个o出现异常了?那么,for会被中止吗?而且,for循环体下面的代码还会被执行吗?

public boolean aa(List<T> bb) {


        for (T o: bb) {

            try {

                method();

            } catch (Exception e) {


                return false;
            }

        }

        System.out.println("ghghfghg");
        return true;

    }

我的想法,去遍历list,看看是否有不合法的内容,有的话,提示出是哪些不合法。不知道这样行不行。有其他方法吗?

PHPz
PHPz

学习是最好的投资!

reply all(1)
Ty80

If you return false;了还会执行么……
如果你把return false; comment it out, it will continue to execute

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template