Card 09/ 09
All 9 cards
RecapDifficulty: Intermediate1 min
One Decision, One Repetition, and the Boundary in Each
Five things this topic established, and where each one was.
| The thing | Where |
|---|---|
An if ladder tests a condition per rung; a switch matches one value | Making the Program Take One Path and Not the Other |
If every rung compares the same variable to a constant, it is a switch | When to Reach for switch and When for else if |
| Four loop forms, separated by how much you know before the loop starts | The Four Shapes of a Java Loop |
A counter from zero compares with <; a counter from one compares with <= | Why Your Retry Policy Tried Four Times |
The colon form of switch picks a starting point, not a branch | Why a switch Without break Keeps Going |
The one worth carrying: in both halves of this topic the bug lives at the boundary rather than in the body. A counter that is one out and a missing break are the same kind of mistake — the code ran one step further than you read it as running.