+ 3

Java Break Statement Breaks For Loop or not?

I have read most of the places that Break statement terminates the for loop and thereafter next statement is executed. But what if you have used break statement inside an IF condition and the IF condition is inside a FOR loop. So when the IF condition is true and break statement is encountered, would the FOR loop be terminated immediately or will it keep getting executed till the time FOR loop condition run out?

23rd Nov 2017, 10:57 AM
KeenCodr
3 Answers
+ 3
When there is a break included the whole loop will not execute. Especially useful to save time
23rd Nov 2017, 11:13 AM
👑 Prometheus 🇾🇬
👑 Prometheus 🇾🇬 - avatar
+ 2
the loop will get terminated whenever it encounters a break statement.
23rd Nov 2017, 11:03 AM
Devbrath
Devbrath - avatar