java奇数次和偶数次进行不同操作

注意要看重点代码,我已经标注
int i=0;
for(Map tid:lists){
    Integer tableid = (Integer) tid.get("tableid");
    AttributeInfo attributeInfo = layoutService.queryTableInfoByTid(tableid);
    Integer outType = attributeInfo.getOut_type();
    //类别:tid
    if(i%2==0){
        leftObject += "{\"id\":"+tableid+",\"outtype\":"+outType+"}";
    }else{
        rightObject += "{\"id\":"+tableid+",\"outtype\":"+outType+"}";
    }
    i++;
    object = "{\"object\":["+leftObject+","+rightObject+"]}";
    model.addAttribute("object",object);
}

你可能感兴趣的:(corejava)