标签:users code turn lse size nta arraylist 相同 int
/**
* 获取两个集合里元素不同的部分
*/
public List<User> getDifferent(List<User> u1, List<User> u2) {
//定义两个空集合
List<User> allUsers = new ArrayList<>();
List<User> differentUsers = new ArrayList<>();
allUsers.addAll(u1);
allUsers.addAll(u2);
for (int i = 0; i < allUsers.size(); i++) {
if (u1.contains(allUsers.get(i)) && u2.contains(allUsers.get(i))) {
continue;
} else {
differentUsers.add(allUsers.get(i));
}
}
return differentUsers;
}
标签:users code turn lse size nta arraylist 相同 int
原文地址:https://www.cnblogs.com/baijinqiang/p/11972418.html