For instance, consider the following code:
boolean found = false;
for (int i = 0; i < arr.length; i++) {
if (Objects.equals(value, arr[i])) {
found = true;
}
}
In this case, iterations have no effect after the condition is met, and you can skip them by adding a break.
boolean found = false;
for (int i = 0; i < arr.length; i++) {
if (Objects.equals(value, arr[i])) {
found = true;
break;
}
}
New in 2019.2