Home Segments Top Top Previous Next

390: Mainline

Suppose that you want more than one statement to be executed when a Boolean expression evaluates to true. You need only to combine the multiple statements, using braces, into a single block.

In the following ifelse statement, for example, two display statements are executed whenever the value of length is greater than 90:

if (length > 90) { 
 System.out.println("It is long!"); 
 System.out.println("It may try your patience"); 
}