+ 1

what is break; in java?

java

7th Oct 2018, 3:24 AM
Adrian Derain
Adrian Derain - avatar
6 ответов
+ 7
Break; is used to 'break' out of a code block like loop. Essentially, it will stop executing the following code in the block and move on For instance if you had a for loop, for(int i = 0; i <= 5; ++i) { if(i == 3){ break; } System.out.println(i); } This loop would only output 1 and 2 as once 3 is hit the loop is broken out of.
7th Oct 2018, 3:37 AM
Voxel
Voxel - avatar
+ 1
When the break statement is encountered inside a loop, the loop is immediately terminated and the program control resumes at the next statement following the loop.
7th Oct 2018, 10:21 AM
Yesha Patel
+ 1
break statement is used to terminate the loop..
7th Oct 2018, 11:52 AM
Pandiselvi
+ 1
The break statement in Java programming language has the following two usages − When the break statement is encountered inside a loop, the loop is immediately terminated and the program control resumes at the next statement following the loop. It can be used to terminate a case in the switch statement (covered in the next chapter).
7th Oct 2018, 1:57 PM
Atish Naik
+ 1
terminator from a space it could be any where in block
13th Oct 2018, 2:03 PM
Aarav Raj
Aarav Raj - avatar
0
break; is a loop breaker statement in Java it also use in c, c++ and python
7th Oct 2018, 5:41 AM
Harinarayan Sahu
Harinarayan Sahu - avatar