zoukankan      html  css  js  c++  java
  • java for 循环continue 跳转到外层

    for (int i = 0; i < cardRecordsList.size(); i++) {
                BomCardRecords bomCardRecords = cardRecordsList.get(i);
                String recordsContent = bomCardRecords.getRecordsContent();
                if (i == 0){
                    recordsContent += "$$$状态";
                }
                String[] contentArr = recordsContent.split("\$\$\$", -1);
                List<String> needData = new ArrayList<>();
                for (int j = 0; j < contentArr.length; j++) {
                    String contentColumn = contentArr[contentArr.length - 1];
                    if (StringUtils.isBlank(state)) {
                        clearUpData(columns, partList, contentArr, columnArr, needData);
                        continue;
                    } else {
                        String[] stateArr = state.split(" ");
                        List<String> stateList = Arrays.asList(stateArr);
                        contentColumn = contentColumn.split(",")[0];
                        if (contentColumn.equals("状态") || stateList.contains(contentColumn)) {
                            clearUpData(columns, partList, contentArr, columnArr, needData);
                            continue;
                        }
                    }
                }
            }
    

      continue 跳出循环

    如上代码我们是嵌套循环 , 当我们循环完毕时需要跳出最外层循环 , 我们只需要在跳转的的地方这么来写

            my:
            for (int i = 0; i < cardRecordsList.size(); i++) {
                BomCardRecords bomCardRecords = cardRecordsList.get(i);
                String recordsContent = bomCardRecords.getRecordsContent();
                if (i == 0){
                    recordsContent += "$$$状态";
                }
                String[] contentArr = recordsContent.split("\$\$\$", -1);
                List<String> needData = new ArrayList<>();
                for (int j = 0; j < contentArr.length; j++) {
                    String contentColumn = contentArr[contentArr.length - 1];
                    if (StringUtils.isBlank(state)) {
                        clearUpData(columns, partList, contentArr, columnArr, needData);
                        continue my;
                    } else {
                        String[] stateArr = state.split(" ");
                        List<String> stateList = Arrays.asList(stateArr);
                        contentColumn = contentColumn.split(",")[0];
                        if (contentColumn.equals("状态") || stateList.contains(contentColumn)) {
                            clearUpData(columns, partList, contentArr, columnArr, needData);
                            continue my;
                        }
                    }
                }
            }

    这样我们就可continue到最外层循环了

  • 相关阅读:
    (备忘)jeecg的$.dialog的一些参数
    jquery中的ajax方法(备忘)
    linux(centos7)设置tomcat开机启动
    centos7设置静态IP地址
    golang 之 sql
    golang 之 flag
    golang 之 context包
    golang 之文件操作
    golang之strings
    golang 函数和方法
  • 原文地址:https://www.cnblogs.com/sunjinggege/p/14779713.html
Copyright © 2011-2022 走看看