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, Fourth Edition now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.