list1<Bean1>和list2<Bean2> 根據元素的playerId屬性 取交集
Bean1和Bean2 都含有playerId屬性
List<Bean1> intersectList = list1.stream()
.filter(pe -> find1(pe.getPlayerId(), list2) > -1).collect(Collectors.toList());
輔助方法find1
public int find1(long playerId,List<PlayerExtra> list) { int res = -1; for (int i = 0; i < list.size(); i++) { if (list.get(i).getPlayerId() == playerId) { res = i; break; } } return res; }
