Nested Loop With Break Statement
What is printed when the following program is executed?
public class NestedBreak {
public static void main(String[] args) {
int count = 0;
for (int i = 0; i < 3; i++){
for (int j = 0; j < 5; j++){
if(j == 2)
break;
count++;
}
}
System.out.println(count);
}
}
A
6
B
9
C
3
D
5
Question Leaderboard
Not enough data yet to show leaderboard.
APFIVE