Using break statement, we can break the loop and continue the execution of rest of code that follows after the loop. We have already discussed the use of break statement in Switch. We can stop the particular case by placing the break statement at the end of the case.
The break statement stops the execution of loop where as the continue statement starts the next iteration of the loop leaving the remaining bock of code. When a continue statement is found, the condition is re-evaluated. If it returns true then it starts the next iteration, if it returns false the control exits the loop.
The below example explains the usage of a continue statement with a while loop. Observe how the continue statement skips the printing of the variable x when the index reaches 5.
The label statement can be used with continue and break statements to control the flow more accurately. A label is simply an identifier
followed by a colon (:) that is applicable to group of statements. Let us see how to use labels with break and continue statements with the help of below examples:
Note –Make sure we should not place any other statement between a label name and corresponding loop.
Java Script Related Tutorials
|Adv Java Tutorial||Core Java Tutorial|
|Java-Springs Tutorial||Java Servlets Tutorial|
|EJB(Enterprise JavaBeans) Tutorial||JavaServer Faces (JSF) Tutorial|
|Java Swing Tutorial||Java Tutorial|
|JavaMail API Tutorial||Java 8 Tutorial|
|Java XML Tutorial||Java Bean Utils Tutorial|
|The Java Debugger (JDB) Tutorial||Java.math Package Tutorial|
Java Script Related Interview Questions
|Java Script Interview Questions||Adv Java Interview Questions|
|Core Java Interview Questions||Java-Springs Interview Questions|
|Java Servlets Interview Questions||EJB(Enterprise JavaBeans) Interview Questions|
|JavaServer Faces (JSF) Interview Questions||Java Swing Interview Questions|
|Java 8 Interview Questions||Java XML Interview Questions|
|JavaFX Interview Questions||The Java Debugger (JDB) Interview Questions|
Java Script Related Practice Tests
|Java Script Practice Tests||Adv Java Practice Tests|
|Core Java Practice Tests||Java-Springs Practice Tests|
|Java Servlets Practice Tests||EJB(Enterprise JavaBeans) Practice Tests|
|JavaServer Faces (JSF) Practice Tests||Java 8 Practice Tests|
All rights reserved © 2020 Wisdom IT Services India Pvt. Ltd
Wisdomjobs.com is one of the best job search sites in India.