So the problem I’m running into is I want to test each part of an array against a condition, and if ALL the parts of the array return false I want to do something but if any of them return true I want to do something else. For example
String[] arr = new String[8];
for(String s : arr) {
if(s.equalsIgnoreCase("example") {
// Do this
} else {
// do that
}
}
The problem with the above is that is will do this or do that for all 8 pieces of the array. What I want is for it to test all of them, and if they’re all false do that but if any of them are true then do this.
The previous answer has the conditions backwards. It was testing if ANY is FALSE, “Do this” and if ALL are TRUE “Do that”. Try this code: