小测试--多层循环跳出方式

private void test(@RequestBody Map<String, Object> paramMap) {
        List<Map<String, Object>> clientLogList = new ArrayList<Map<String, Object>>();
        Map<String, Object> a1 = new HashMap<String, Object>();
        a1.put("id", "001");
        a1.put("aa1", "aa000011");
        a1.put("aa2", "aa000021");
        
        Map<String, Object> a2 = new HashMap<String, Object>();
        a2.put("id", "002");
        a2.put("aa1", "aa000012");
        a2.put("aa2", "aa000022");
        Map<String, Object> a3 = new HashMap<String, Object>();
        a3.put("id", "002");
        a3.put("aa1", "aa000013");
        a3.put("aa2", "aa000023");
        Map<String, Object> a4 = new HashMap<String, Object>();
        a4.put("id", "003");
        a4.put("aa1", "aa000014");
        a4.put("aa2", "aa000024");
        Map<String, Object> a5 = new HashMap<String, Object>();
        a5.put("id", "003");
        a5.put("aa1", "aa000015");
        a5.put("aa2", "aa000025");
        Map<String, Object> a6 = new HashMap<String, Object>();
        a6.put("id", "003");
        a6.put("aa1", "aa000016");
        a6.put("aa2", "aa000026");
        clientLogList.add(a1);
        clientLogList.add(a2);
        clientLogList.add(a3);
        clientLogList.add(a4);
        clientLogList.add(a5);
        clientLogList.add(a6);
        
        
        
        List<Map<String, Object>> firstLogList = new ArrayList<Map<String, Object>>();
        Map<String, Object> b1 = new HashMap<String, Object>();
        b1.put("id", "001");
        b1.put("bb1", "bb000011");
        b1.put("bb2", "bb000021");
        Map<String, Object> b2 = new HashMap<String, Object>();
        b2.put("id", "002");
        b2.put("bb1", "bb000012");
        b2.put("bb2", "bb000022");
        Map<String, Object> b3 = new HashMap<String, Object>();
        b3.put("id", "003");
        b3.put("bb1", "bb000013");
        b3.put("bb2", "bb000023");
        firstLogList.add(b1);
        firstLogList.add(b2);
        firstLogList.add(b3);
        
        
        
       A: for (Map<String, Object> clientLogMap:clientLogList) {
            String clogUserid = (String) clientLogMap.get("id");
           B: for (Map<String, Object> firstLog:firstLogList) {
                String flogUserid = (String) firstLog.get("id");//去除两种空格格式
                //4.4 当firstlog表的userid==clientlog表的userid时,将displayname和usercn封装到本次查询结果的clientLogMap中
                if (flogUserid.equalsIgnoreCase(clogUserid)) {
                    clientLogMap.put("bb1", firstLog.get("bb1")); 
                    clientLogMap.put("bb2", firstLog.get("bb2"));
                    break;// break语句对if-else的条件语句不起作用(continue对其起作用);在多层循环中, 一个break语句只向外跳一层。
                }
            }
        }
    }
    
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值