Conditionals and Loops
Choosing which code runs with if and switch, repeating it with Java's four loop forms, and the boundary mistakes in both.
Two ways a Java program controls which lines run: conditionals, which choose between paths, and loops, which repeat a block of code. You know both ideas from other languages; what is specific to Java is the choice between if and switch, the four loop forms, and two mistakes that compile, run and give the wrong answer. It covers if and else if, both forms of switch, the counted and enhanced for, while and do/while, and break and continue. It leaves out labelled break and pattern matching in switch, which belong with records and sealed types.
Contents
9 cardsnot started