把try{}catch(Exception e){}放for循环里面啊,for要做的事情放try{}里啊:
boolean flag=true;
for(int i=0;i<10;i++){
 try{
 //...
 }catch(Exception e){
  //System.out.println(FALSE);
  flag=false;
  //continue;
  }
}
return flag;
//不知道能否满足要求,你试下吧
//循环继续的指令是continue,循环终止跳出用break;

解决方案 »

  1.   

    在外面捕获异常,循环中出现异常后边的循环不会执行。如果你有return,那return后的代码也都不会执行。
    把代码贴出来研究一下怎么写吧。
      

  2.   


        public static void main(String[] args) {
            int i = 0;
            String[] s = { "1", "2", "3", "4", "5", "6", "7", "8", "9", "10", "11" };
            System.out.println(loop(i, s));    }    public static boolean loop(int i, String[] s) {
            try {
                for (int iSize = s.length; i < iSize; i++) {
                    if (i == 5) {
                        throw new Exception(i + ":这里抛出异常!");
                    }
                    System.out.println(i + ":" + s[i]);
                }
            } catch (Exception e) {
                loop(i + 1, s);
                return false;
            }
            return true;
        }
      

  3.   

    出现异常了 如果你的return放在catch块里 
    循环应该就不会继续了,整个方法就退出了
    如果要让循环继续,catch块里面用continue;
    try--catch块放在循环里面
      

  4.   


    public static void main(String[] args) { method(); } public static void method() {
    for (int i = 0; i < 10; i++) {
    try { int k = 10 / i;
    System.out.println(k); } catch (Exception e) {
    e.printStackTrace();
    continue;
    }
    }
    }
      

  5.   

    你希望出现异常时方法返回值为false,不出现异常方法返回值为true
    但无论是否有异常,循环都需要执行完,是这个意思不?
      

  6.   

    代码比如:
    for(xxxx){
      methoda();
    }
    在methoda()里我做了try/catch,那如果异常了,循环继续否?
      

  7.   

    public class Test {
        public static void main(String[] args) {
            int i = 0;
            String[] s = { "1", "2", "3", "4", "5", "6", "7", "8", "9", "10", "11" };
            System.out.println(loop(s));    }    public static boolean loop(String[] s) {
         boolean a = true;
            
                for (int i = 0; i < s.length; i++) {
                 try {
                    if (i == 5) {
                        throw new Exception(i + ":这里抛出异常!");
                    }
                    System.out.println(i + ":" + s[i]);
                    } catch (Exception e) {
                        a=false;
                        continue;
                    }
                }
            return a;
        }
    结合楼上二位,呵呵。lisong526的有递归,gjsong的没有返回值。
      

  8.   

    那要看你的methoda里面对异常怎么处理了,如果你try-catch捕获了,那么你的for循环是否会继续要看你循环里面怎么写逻辑了
    但是如果你是在methoda里throw得异常for循环也会终止的