public List<RefundTreeResp> getTreeList(List<RefundTreeResp> oldList, List<RefundTreeResp> newList) { // 创建一个新的List集合实例,用来保存相加之后的数对象 List<RefundTreeResp> refundTreeRespList = new ArrayList<>(); // 循环旧的数组,并获取到里面需要进行运算的值,根据下标获取到新数组里面的值进行相加(场景 当两个List集合对象是一样的情况下) for (int i = 0; i < oldList.size(); i++) { RefundTreeResp resp = new RefundTreeResp(); Integer oldValue = oldList.get(i).getValue(); Integer newValue = newList.get(i).getValue(); resp.setName(oldList.get(i).getName()); resp.setValue(oldValue + newValue); refundTreeRespList.add(resp); } return refundTreeRespList; }
相关文章
暂无评论...