I want to use Java lambda expression for an intersection of two lists and then ever with lambda expression I want to delete from the list.
Example: I have
List<Person> first = new ArrayList<Person>();
List<Person> second = new ArrayList<Person>();
Suppose that both lists have some Person Object. I want put into List temp intersection of two list filtered by name for example:
List<Person> temp = new ArrayList<>();
for (Person one : first) {
for (Person two : second) {
if(one.getName.equals(two.getName)) {
temp.add(two);
}
}
}
Then I want to remove some Person from temp using a filter, for example, using the Surname.
for (Person tmp : temp) {
for (Person one : first) {
if (one.getSurname.equals(tmp.getSurname)) {
temp.remove(tmp);
}
}
}
I want to use lambda expression, How i can do?