I'm trying to verify if my list myList
getName() contains at least one value of a set names
.
I created a method for it, but I'm wondering if there is a simpler way in Java.
private boolean validateMyList(List<myObject> myList, Set<String> names) {
for(myObject obj : myList) {
if(names.contains(obj.getName())) {
return true;
}
}
return false;
}