break; is what you need to break out of any looping statement like for, while or do-while.

In your case, its going to be like this:-

for(int x = 10; x < 20; x++) {
         // The below condition can be present before or after your sysouts, depending on your needs.
         if(x == 15){
             break; // A unlabeled break is enough. You don't need a labeled break here.
         }
         System.out.print("value of x : " + x );
         System.out.print("\n");
}
Answer from Rahul on Stack Overflow
🌐
W3Schools
w3schools.com › java › java_break.asp
Java Break and Continue
How Tos Add Two Numbers Swap Two ... Loop Loop Through an Enum ... assert abstract boolean break byte case catch char class continue default do double else enum exports extends final finally float for if implements import instanceof int interface long module native new package private protected public return requires short static super switch synchronized this throw throws transient try var void volatile while Java String ...
Discussions

Can break; statements be used in for loop?
My Professor deducted points from a Java project I turned in stating “Break statements should not be used except in a switch.” I don’t think that’s true. What other way is there to break out of a for loop without “break;”? More on reddit.com
🌐 r/javahelp
8
0
October 8, 2021
How do I break out of nested loops in Java? - Stack Overflow
@Tvde1 and still useful for other users, so new methods and solutions are always welcome 2019-04-16T04:32:46.347Z+00:00 ... Labeled break concept is used to break out nested loops in java, by using labeled break you can break nesting of loops at any position. More on stackoverflow.com
🌐 stackoverflow.com
Best Practice: Avoid break statement in for loops - Oracle Forums
Hello everyone !! Recently I had a discussion with my architect regarding use of break statements in for/while loops in java. He suggested, we should avoid break statements in for loops as it works ... More on forums.oracle.com
🌐 forums.oracle.com
October 6, 2007
Is it bad practice to use break in loops?
Need more context. Sorry but I doubt your instructor said "break statements may confuse, don't use them". This is bad practice: while (true) { if (something) { break; } } Put the condition inside the condition statement whenever possible. Either way you need to follow the style your instructor tells you. More on reddit.com
🌐 r/learnprogramming
11
1
January 27, 2020
🌐
GeeksforGeeks
geeksforgeeks.org › java › java-for-loop-with-examples
Java For Loop - GeeksforGeeks
3 weeks ago - Note: A "Time Limit Exceeded" error occurs when a program runs longer than the time allocated for execution, due to infinite loops. This is ideal for iterating over a known range or collection. Efficient syntax for initialization, condition checking, and incrementing.
🌐
GeeksforGeeks
geeksforgeeks.org › java › break-statement-in-java
Java Break Statement - GeeksforGeeks
Using break, we can force immediate termination of a loop, bypassing the conditional expression and any remaining code in the body of the loop. Note: Break, when used inside a set of nested loops, will only break out of the innermost loop.
Published   July 12, 2025
🌐
Reddit
reddit.com › r/javahelp › can break; statements be used in for loop?
r/javahelp on Reddit: Can break; statements be used in for loop?
October 8, 2021 - You can have a condition in the loop in such a way that instead of breaking out of the loop, the loop continues to the end, but not do anything (bad practice, though). You could, instead continue from the point on where you would break (again, bad practice) You could add another termination condition in the for loop.
🌐
DataCamp
datacamp.com › doc › java › break
break Keyword in Java: Usage & Examples
The break keyword in Java is used to terminate the execution of a loop or switch statement prematurely. When a break statement is encountered, control is transferred to the statement immediately following the enclosing loop or switch. The break statement is commonly used in the following scenarios: ...
Find elsewhere
🌐
Crunchify
crunchify.com › java j2ee tutorials › in java how to break a loop from outside? multiple ways
In Java how to break a loop from outside? Multiple ways • Crunchify
April 22, 2023 - In Java, it is possible to break out of a loop from outside the loop's function by using a labeled break statement. This can be useful when you need to
🌐
GeeksforGeeks
geeksforgeeks.org › java › break-and-continue-statement-in-java
Break and Continue statement in Java - GeeksforGeeks
Using break, we can force immediate termination of a loop, bypassing the conditional expression and any remaining code in the body of the loop.
Published   1 month ago
🌐
Programiz
programiz.com › java-programming › break-statement
Java break Statement (With Examples)
In the above example, the labeled break statement is used to terminate the loop labeled as first. That is, ... Here, if we change the statement break first; to break second; the program will behave differently. In this case, for loop labeled as second will be terminated.
🌐
Quora
quora.com › Java-How-could-I-break-out-of-an-inner-loop-and-continue-through-the-next-most-inner-loop-upon-a-condition
Java: How could I break out of an inner loop and continue through the next most inner loop, upon a condition? - Quora
Answer (1 of 6): Edit (thanks Bernard Leak for pointing this out): Changing my answer to capture the question intent as per a comment by the OP on another answer. The main point is that there are two loops and we want to execute code in the outer loop upon a condition in the inner one. The loops ...
🌐
Oracle
docs.oracle.com › javase › tutorial › java › nutsandbolts › branch.html
Branching Statements (The Java™ Tutorials > Learning the Java Language > Language Basics)
The break statement, shown in boldface, terminates the for loop when that value is found. Control flow then transfers to the statement after the for loop.
🌐
Oracle
forums.oracle.com › ords › apexds › post › best-practice-avoid-break-statement-in-for-loops-1264
Best Practice: Avoid break statement in for loops - Oracle Forums
October 6, 2007 - Hello everyone !! Recently I had a discussion with my architect regarding use of break statements in for/while loops in java. He suggested, we should avoid break statements in for loops as it works ...
🌐
Quora
quora.com › How-do-I-break-a-nested-for-loop-in-Java
How to break a nested for loop in Java - Quora
Originally Answered: Learning programming: How do I break out of nested loops in Java? · ... Deeply nested loops, say 10+ levels, can be difficult to optimize and fit on the stack. It might result in cache misses slowing down performance. do while is more effecient. A method checked by while can increment state. I have used this approach for complex structures iterating over all possible variations of 14 different parameters, which logically fits in 14 nested loops.
🌐
CodeSignal
codesignal.com › learn › courses › iterations-and-loops-in-java › lessons › navigating-loop-control-mastering-break-and-continue-in-java
Navigating Loop Control: Mastering Break and Continue in ...
We're taking a leap today to learn break and continue, our control tools in Java loops. break works as an exit, allowing you to leave a loop early, while continue assists in skipping unneeded iterations.
🌐
W3Schools
w3schools.com › js › js_break.asp
W3Schools.com
The break statement exits a loop or block and transfers the control to the labeled statement. The break statement is particularly useful for breaking out of inner or outer loops from nested loops.
🌐
Medium
medium.com › @tabinda1030 › java-break-statement-controlling-the-flow-63a7a2b3d5ab
Java Break Statement : Controlling the flow | by Tabinda Hayat | Medium
July 18, 2023 - At this point, the labeled break statement is executed, causing the program to break out of the outer loop entirely. Consequently, the inner loop is terminated as well. In summary, the Java break statement is a powerful tool used to control the flow of execution within loops and switch statements.
🌐
Baeldung
baeldung.com › home › java › core java › the java continue and break keywords
The Java continue and break Keywords | Baeldung
January 8, 2024 - In this quick article, we’ll ... break Java keywords and focus on how to use them in practice. Simply put, execution of these statements causes branching of the current control flow and terminates the execution of the code in the current iteration. The break statement comes in two forms: unlabeled and labeled. We can use the unlabeled statement to terminate a for, while or do-while loop as well as ...
🌐
TutorialsPoint
tutorialspoint.com › break-continue-and-label-in-java-loop
break, continue and label in Java loop
March 20, 2025 - The loop will print out the numbers 0 through 6 and then break when the value of numval reaches 7. The continue statement is applied to bypass the current iteration of a loop and proceed to the next iteration. The program will bypass the rest of the code in the current iteration once the continue ...
🌐
O'Reilly
oreilly.com › library › view › java-a-beginners › 9780071606325 › ch3lev1sec17.html
Use break to Exit a Loop - Java, A Beginner's Guide, 5th Edition, 5th Edition [Book]
September 10, 2011 - Content preview from Java, A Beginner's ... test, by using the break statement. When a break statement is encountered inside a loop, the loop is terminated and program control resumes at the next statement following the loop...
Author   Herbert Schildt
Published   2011
Pages   650