In my Java application I have a class:
public class MyStructure {
    SomeClass someClass;
    String[] fields;
    ...
}
Now, I have a list of the structures above:
List< MyStructure> structures = getStructures();
I also have a list of Strings:
List<String> myList = getStrings();
I need to filter the first list (structures) so that it only contains elements, that in their fields array contain any of the Strings present on myList.
I thought about writing a for loops, something like:
List<MyStructure> outcomeStructures = new ArrayList<>(); 
for (MyStructure mystructure : structures) {
    for (String temp : mystructure.getFields()) {
        if (myList.contains(temp) {
            outcomeStructures.add(mystructure);
        }
    }
}
but maybe there's a better way to do so? Thanks!
 
     
    