I'm looking for a statment to check if there is any match in two lists of Users, according to Username.
List<User> a;
List<User> b;
for (User user : a) {
for (User newUser : b) {
if (user.getName().equals(newUser.getName())) {
}
}
}
How can I write this in java 8? Somthing like this:
List<User> intersect = a.stream()
.filter(User::getName)
.collect(Collectors.toList());