8/14/25, 9:51 PM Java Break and Continue
Tutorials Exercises Services Sign In
HTML
CSS JAVASCRIPT SQL PYTHON JAVA PHP HOW TO [Link] C
Java Break and Continue
❮ Previous Next ❯
Java Break
You have already seen the break statement used in an earlier chapter of this tutorial. It
was used to "jump out" of a switch statement.
The break statement can also be used to jump out of a loop.
This example stops the loop when i is equal to 4:
Example Get your own Java Server
for (int i = 0; i < 10; i++) {
if (i == 4) {
break;
}
[Link](i);
}
Try it Yourself »
Java Continue
[Link] 1/6
8/14/25, 9:51 PM Java Break and Continue
The continue statement breaks one iteration (in the loop), if a specified condition occurs,
Tutorials Exercises Services
and continues with the next iteration in the loop.
Sign In
HTML
CSS JAVASCRIPT SQL PYTHON JAVA PHP HOW TO [Link] C
This example skips the value of 4:
Example
for (int i = 0; i < 10; i++) {
if (i == 4) {
continue;
}
[Link](i);
}
Try it Yourself »
Break and Continue in While Loop
You can also use break and continue in while loops:
Break Example
int i = 0;
while (i < 10) {
[Link](i);
i++;
if (i == 4) {
break;
}
}
Try it Yourself »
[Link] 2/6
8/14/25, 9:51 PM Java Break and Continue
Tutorials
Continue Exercises
Example Services Sign In
HTML
CSS JAVASCRIPT SQL PYTHON JAVA PHP HOW TO [Link] C
int i = 0;
while (i < 10) {
if (i == 4) {
i++;
continue;
}
[Link](i);
i++;
}
Try it Yourself »
?
Exercise
True or False:
The break statement can only be used within switch statements.
True
False
Submit Answer »
❮ Previous Next ❯
[Link] 3/6
8/14/25, 9:51 PM Java Break and Continue
Tutorials Exercises Services Sign In
HTML
CSS Track your
JAVASCRIPT SQLprogress
PYTHON- it'sJAVA
free! PHP SignHOW
Up TOLog [Link] C
COLOR PICKER
PLUS SPACES
[Link] 4/6
8/14/25, 9:51 PM Java Break and Continue
Tutorials Exercises
GET CERTIFIED
Services
FOR TEACHERS
Sign In
HTML
CSS JAVASCRIPT SQL PYTHON JAVA PHP HOW TO [Link] C
FOR BUSINESS CONTACT US
Top Tutorials
HTML Tutorial
CSS Tutorial
JavaScript Tutorial
How To Tutorial
SQL Tutorial
Python Tutorial
[Link] Tutorial
Bootstrap Tutorial
PHP Tutorial
Java Tutorial
C++ Tutorial
jQuery Tutorial
Top References
HTML Reference
CSS Reference
JavaScript Reference
SQL Reference
Python Reference
[Link] Reference
Bootstrap Reference
PHP Reference
HTML Colors
Java Reference
Angular Reference
jQuery Reference
Top Examples Get Certified
HTML Examples HTML Certificate
CSS Examples CSS Certificate
JavaScript Examples JavaScript Certificate
How To Examples Front End Certificate
SQL Examples SQL Certificate
Python Examples Python Certificate
[Link] Examples PHP Certificate
Bootstrap Examples jQuery Certificate
PHP Examples Java Certificate
Java Examples C++ Certificate
XML Examples C# Certificate
jQuery Examples XML Certificate
FORUM ABOUT ACADEMY
[Link] 5/6
8/14/25, 9:51 PM Java Break and Continue
W3Schools is optimized for learning and training. Examples might be simplified to improve reading and
Tutorials Exercises learning.
Services
Tutorials, references, and examples are constantly reviewed to avoid errors, but we cannot warrant full
correctness
Sign In
of all content. While using W3Schools, you agree to have read and accepted our terms of use, cookie
HTML
CSS JAVASCRIPT SQL PYTHON JAVA PHP HOW TO [Link] C
and privacy policy.
Copyright 1999-2025 by Refsnes Data. All Rights Reserved. W3Schools is Powered by [Link].
[Link] 6/6