您的位置:首页 > 编程语言 > Java开发

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

2011-11-16 11:16 169 查看
//需求:对结果集(已经从数据库中得到结果集)进行过滤,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 fiber
String 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 unique
IR ir = list.get(i);
cablecore = ir.getCableCode();
fiberdp = ir.getFiberDp();
mfibercode = ir.getFiberCore();
//the first: fiber not null
if(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);
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: