← Java Programming learning pathJava Programming · Module 3 of 10
Operators, conditions and loops
Control program flow with if, switch, for, while and do-while.
📖 Key ideas
- if / else if / else choose a path.
- switch selects by value; modern Java has switch expressions with ->.
- for (int i = 0; i < n; i++) repeats a known number of times.
- while and do-while repeat on a condition.
- Enhanced for: for (String s : names) visits each item.
💡 Real-life example: Loops are like a teacher calling roll: go through each student until the list ends.
switchChooses a branch by value
Enhanced forLoops over each element
do-whileRuns at least once
&&Logical AND