In the 2nd iteration , when "b".equals(s) is true , the if executes "continue" , right? so it goes to the 3rd iteration, but...public class TestClass {
public static void main(String[] args) throws Exception {
String[] sa = {"a", "b", "c"};
for(String s :sa){
if("b".equals(s)) continue;
System.out.println(s);
if("b".equals(s)) break;
System.out.println(s+" again");
}
}
}
why isn´t the rest of the code unreachable, ending in a compilation fail ?:
System.out.println(s);
if("b".equals(s)) break;
System.out.println(s+" again");