In the below example , someObjects is a set. I am trying to return true if a condition matches within the loop , however this doesn't seem to compile. However when I just add "return" it works fine.What is the issue that I need to fix?
public boolean find(){
someObjects.forEach(obj -> {
if (some_condition_met) {
return true;
}
});
return false;
}
Compilation Errors
The method forEach(Consumer) in the type Iterable is not applicable for the arguments (( obj) -> {})