O'Reilly logo

Special Edition Using Java 2 Standard Edition by Geoff Friesen, Chuck Cavaness, Brian Keeton

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

Control Flow Functions

Control flow is the heart of any program. It is the capability to adjust (control) the way that a program progresses (flows). By directing the paths of execution that your code takes, you build programs that behave dynamically based on their inputs. Without control flow, programs would not be able to do anything more than several sequential operations.

if Statements

The simplest form of control flow is the if statement. An if statement checks its conditional expression (typically derived through any of the means described in the first half of this chapter) and, if the value is true, directs the interpreter to execute the next block of code. The general syntax for the if statement is as follows:

 if (expression) statement; ...

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