class Test7 {
public static void main(String[] args) {
for (int i = 1; i <= 10; ++i) {
if (i == 5) {
break;
}
System.out.println(i);
}
}
}
When you run the program, the output will be:
1
2
3
4
Explanation:- In the above program, when the value of a becomes 5, expression i == 5 inside the parenthesis of if statement is evaluated to true. Then, The break statement is executed terminates the
Explanation:- In the above program, when the value of a becomes 5, expression i == 5 inside the parenthesis of if statement is evaluated to true. Then, The break statement is executed terminates the
0 comments:
Post a Comment