home | O'Reilly's CD bookshelfs | FreeBSD | Linux | Cisco | Cisco Exam  


Java Language Reference

Previous Chapter 6
Statements and Control Structures
Next
 

6.3 The Empty Statement

The empty statement does nothing:

[Graphic: Figure from the text]

The empty statement can be useful as a place holder. For example, if a for statement contains all of the necessary functionality in its header, the body of the for statement can be the empty statement. Here's an example:

// Find the first element of array nx that equals 5
int x;
for (x = 0; x < nx.length && nx[x] != 5; x++)
// for requires a statement here: use an empty statement
    ;
if (x < nx.length) {
// The for statement found a 5 at nx[x]
}


Previous Home Next
Labeled Statements Book Index Expression Statements

Java in a Nutshell Java Language Reference Java AWT Java Fundamental Classes Exploring Java