Break will leave the loop, so booth solutions will only ‘iterate’ over the first item.
The second solution without break would be right.
(Both solutions would work if you use continue instead of break)
solved If Else Best Approach In Java [closed]