4.1. Introduction

Before writing a program to solve a problem, you must have a thorough understanding of the problem and a carefully planned approach to solving it. When writing a program, you also must understand the types of building blocks that are available and employ proven program-construction techniques. In this chapter and in Chapter 5, Control Statements: Part 2, we discuss these issues in our presentation of the theory and principles of structured programming. The concepts presented here are crucial in building classes and manipulating objects.

In this chapter, we introduce Java’s if...else and while statements, three of the building blocks that allow programmers to specify the logic required for methods to perform their tasks. We ...

Get Java™ How to Program, Seventh Edition 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.