import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
public class ceshi {
public static void main(String[] args) {
List<实体类> one = new ArrayList<>();
实体类 vo = new 实体类();
vo.setMatchRingId(12345);
vo.setBoss1BetCount("值1");
vo.setBoss2BetCount("值2");
vo.setWinType(1);
vo.setRewardCount("值3");
vo.setRingType(4);
vo.setPump("值5");
one.add(vo);
List<实体类> two = new ArrayList<>();
实体类 vos = new 实体类();
vos.setMatchRingId(12345);
vos.setNzTotal("99999");
vos.setAbTotal("88888");
two.add(vos);
System.out.println("集合1长度:" + one.size() + "==集合2长度:" + two.size());
Map<Integer, 实体类> map = two.stream()
.collect(Collectors.toMap(实体类::getMatchRingId, match -> match));
one.forEach(n -> {
if (map.containsKey(n.getMatchRingId())) {
实体类 obj = map.get(n.getMatchRingId());
n.setAbTotal(obj.getAbTotal());
n.setNzTotal(obj.getNzTotal());
}
});
one.forEach(m -> {
System.out.println(m.getMatchRingId() + "==" + m.getNzTotal() + "==" + m.getPump());
});
}
}
|