loops
10 tutorials tagged “loops”.
- Java Break StatementLeave a loop or a switch early with break: stopping a search when you find what you need, break inside switch, and how break behaves in nested loops.
- Java Continue StatementSkip the rest of one loop round with continue: filtering items, how continue behaves in for, while and do-while loops, and when an if-else reads better.
- Java Do-While LoopThe loop that runs its body at least once: do-while syntax, how it differs from while, menus and input checks that suit it, and the semicolon it needs.
- Java For-Each LoopVisit every element of an array or list with the enhanced for loop: syntax, how it compares with a counting for loop, and what it can and can't do.
- Infinite LoopsLoops that never end: the usual causes, how to stop a stuck program, and the intentional while (true) loop with break used in servers and menus.
- Java for LoopRepeat code a known number of times with the for loop: its four parts, the exact order they run in, counting up, down and in steps, and off-by-one mistakes.
- Labeled Break and ContinueName a loop with a label so break can leave nested loops at once and continue can jump to the outer loop's next round, and when to use a method.
- Nested LoopsA loop inside a loop: how the inner loop runs fully for each outer round, tables and grids, counting total rounds, and keeping it readable.
- Traversing ArraysVisit every element of an array with a for loop or a for-each loop, go backwards or skip elements, find totals, maximums and positions, and pick the right loop.
- Java While LoopRepeat code while a condition stays true, when the number of rounds isn't known in advance: how while works, input loops, and loops that never end.