两个list 集合比较属性不同的值
for(Stall stall : stallList){ boolean flag = false; for(DeliveryStallCommission deliveryStallCommission : riderList){ if(stall.getId() ==deliveryStallCommission.getStallId().longValue()){ flag=true; break; } } if(!flag){//表示stallList 的stall.getid值不存在于 riderList 的delivertStallCommission.getStallId DeliveryStallCommission deliveryStallCommission = new DeliveryStallCommission(); deliveryStallCommission.setStallId(stall.getId().intValue()); deliveryStallCommission.setStallName(stall.getName()); riderList.add(deliveryStallCommission); } }