foreach嵌套遍历循环的问题

在foreach嵌套循环中使用==和equals的问题

JSONArray ja1= new JSONArray();
        JSONArray ja2 = new JSONArray();
        JSONObject jo1 = new JSONObject();
        JSONObject jo2 = new JSONObject();

        for(Person p:person){
            jo1.put("id",p.getId());
            jo1.put("name",p.getName());
            jo1.put("code",p.getCode());
            jo1.put("cardid",p.getCardid());
            jo1.put("sex",p.getSex());
            jo1.put("birthday",p.getBirthday());
            jo1.put("phone",p.getPhone());
            jo1.put("corp_code",p.getCorp_code());
            jo1.put("dept_code",p.getDept_code());
            String pk1 = p.getPk_psndoc();

            List bankCard = p.getBc();
            for(BankCard c:bankCard){
                String pk2 = c.getPk_psndoc();
                if(pk2.equals(pk1)){
                    jo2.put("name",c.getName());
                    jo2.put("code",c.getCode());
                    jo2.put("bank",c.getBank());
                    jo2.put("cardtype",c.getCardtype());
                    jo2.put("id",c.getPk_bankcard());
                    ja2.add(jo2);

                }
            }

            jo1.put("bodybank_card",ja2);
            ja1.add(jo1);
            ja2.clear();

        }

在嵌套的内循环中用equals比较,,,,,

转载于:https://www.cnblogs.com/gxlaqj/p/10291268.html

你可能感兴趣的:(foreach嵌套遍历循环的问题)