5.1 Introduction
This chapter continues our presentation of structured programming theory and principles by introducing all but one of Java’s remaining control statements. We demonstrate Java’s for
, do
...while
and switch
statements. Through a series of short examples using while
and for
, we explore the essentials of counter-controlled repetition. We use a switch
statement to count the number of A, B, C, D and F grade equivalents in a set of numeric grades entered by the user. We introduce the break
and continue
program-control statements. We discuss Java’s logical operators, which enable you to use more complex conditional expressions in control statements. Finally, we summarize Java’s control statements and the proven problem-solving techniques ...
Get Java™ How To Program (Early Objects), Tenth Edition 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.