Intellipaat Back

Explore Courses Blog Tutorials Interview Questions
0 votes
4 views
in Java by (6.5k points)
How is it implemented?

1 Answer

0 votes
by (11.3k points)

The 'break' statement terminates the immediate loop that it is written under. And unlike the 'continue' statement, the loop does not move on to the next iterative cycle. This statement is usually used to reduce the time taken if all the redundant of the lines of code are not executed for the build being worked on. 

for (int i=1;i<=3;i++)

{

                  if (i==2)

                  break;

                  System.out.println(i);

}

The above will print:

1

Statements like break and continue are pretty important if you're looking to learn java, it is highly recommended to understand these concepts.

Related questions

31k questions

32.8k answers

501 comments

693 users

Browse Categories

...