O'Reilly logo

Java: A Beginner’s Tutorial, 4th Edition (Updated for Java SE 8) by Budi Kurniawan

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Chapter 3

Statements

A computer program is a compilation of instructions called statements. There are many types of statements in Java and some—such as if, while, for, and switch—are conditional statements that determine the program flow. This chapter discusses Java statements, starting with an overview and then providing details of each of them. The return statement, which is the statement to exit a method, is discussed in Chapter 4, “Objects and Classes.”

Overview

In programming, a statement is an instruction to do something. Statements control the sequence of program execution. Assigning a value to a variable is an example of a statement.

x = z + 5;

Even a variable declaration is a statement.

long secondsElapsed;

By contrast, an expression ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required