Given:
public class DoBreak1 {
public static void main(String[] args) {
String[] table = {"aa", "bb", "cc", "dd"};
for (String ss: table) {
if ( "bb".equals(ss)) {
continue;
}
System.out.println(ss);
if ( "cc".equals(ss)) {
break;
}
What is the result?
A.
aa
cc
B.
aa
bb
cc
C.
cc
dd
D.
cc
E.
Compilation fails.
so continue brings it to the next iteration of the loop
so i get why it prints aa, skips bb and then prints cc but wouldn’t it also print out dd
can anyone explain?
Breaks out of loop after printing cc