Sorry if title isn't super clear.
I have two ways to do this where: c is an iterable of Objects
boolean condition = false;
for (Object o : c) {
if (meetsCondition(o)) {
condition = true;
break;
}
}
boolean condition = false;
Iterator<Object> iter = c.iterator();
while (!condition && iter.hasNext()) if (meetsCondition(iter.next())) condition = true;
If Object o meets a condition that is described using the method meetsCondition() then I would like to update the result and stop looping as the program only requires one of the objects to meet this condition.
Unsure as to what is the best practice as have been informed that using break is not good practice.
Thank you.