首页 > java深刻理解try-catch....?

java深刻理解try-catch....?

我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,看看是否有不合法的内容,有的话,提示出是哪些不合法。不知道这样行不行。有其他方法吗?


你都 return false;了还会执行么……
如果你把return false;注释掉就会继续执行了

【热门文章】
【热门文章】