java中利用标记跳出多重循环

来源:互联网 发布:手机淘宝怎么批量退款 编辑:程序博客网 时间:2024/05/18 00:53

//需求:对结果集(已经从数据库中得到结果集)进行过滤,List<IR> IR为实体//条件:(1)不能为空(2)最终得到的结果集不能为空//实质就是把过滤好的结果集放到另一个结果集中。                List<IR> list = irDao.findNoPageIRList(params, searchTemplate);List<IR> resultNoPageList = new ArrayList<IR>();//export excel resutl on the basis of fiberString cablecore="";String fiberdp = "";String mfibercode = "";IR ir0 = list.get(0);resultNoPageList.add(ir0);out://标记for(int i=1;i<list.size();i++){//cablecore fiberdp mfibercode uniqueIR ir = list.get(i);cablecore = ir.getCableCode();fiberdp = ir.getFiberDp();mfibercode = ir.getFiberCore();//the first: fiber not nullif(cablecore==null&&fiberdp==null&&mfibercode==null){continue;}//the second: is not repeat  for(int j=0;j<resultNoPageList.size();j++){IR resultIR  = resultNoPageList.get(j);if((cablecore.equals(resultIR.getCableCode())  &&fiberdp.equals(resultIR.getFiberDp())  &&mfibercode.equals(resultIR.getFiberCore()))){continue out;// to the next loop(outer)}}//the last: add to resultList resultNoPageList.add(ir);}