© Karl Beecher 2018
Karl BeecherBad Programming Practices 101https://doi.org/10.1007/978-1-4842-3411-2_5

5. Loops

Karl Beecher1 
(1)
Berlin, Germany
 

Objectives

In this chapter, you’ll learn:
  • How to match different types of loops to the wrong situations

  • How to make your program prone to freezing by incorporating infinite loops

  • How to compromise the structuredness of loops

  • Various ways to make loops excessively long and complex

Prerequisites

Before reading this chapter, make sure you’re familiar with:
  • Loops in Java:
    • For loop

    • Foreach loop

    • While (or do while) loop

  • The basic idea of collections (e.g., List, Set, Queue)

  • Iterators

  • Reading keyboard input using the Scanner class

Introduction

Like conditionals, loops are a fundamental control structure in programming. ...

Get Bad Programming Practices 101: Become a Better Coder by Learning How (Not) to Program now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.