Program Flow  «Prev  Next»

Break Statement - Exercise

Using Java Break Statement

Objective: Practice using the break statement to exit an infinite loop in Java.

Exercise Grading

The full credit for this exercise is 10 points. To receive full credit, you will need to successfully create the source code for the application. You will submit your source code.

Exercise instructions

Develop a command-line application named BreakLoop that enters an infinite do loop and repeatedly prints the text "I'm stuck!".
Then add an integer counter and use the break statement to bail out of the loop after looping 10 times.

What to submit:

In the text box below, cut and paste the source code for the BreakLoop application. Click the Submit to submit the code .