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 whileand for, we explore the essentials of counter-controlled iteration. 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 ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access