F. Labeled break and continue Statements

F.1 Introduction

In Chapter 5, we discussed Java’s break and continue statements, which enable programmers to alter the flow of control in control statements. Java also provides the labeled break and continue statements for cases in which a programmer needs to conveniently alter the flow of control in nested control statements. This appendix demonstrates the labeled break and continue statements with examples using nested for statements.

F.2 Labeled break Statement

The break statement presented in Section 5.8.1 enables a program to break out of the while, for, do...while or switch in which the break statement appears. Sometimes these control statements are nested in other iteration statements. A program ...

Get Java 9 for Programmers now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.