Expression Statements

Certain kinds of expression are counted as statements. You write any expression, put a semicolon after it, and voila, it's an expression statement. In particular, an assignment, method invocation, the creation of a object by calling a constructor (looks like a method call, and the keyword “new” is used so we can tell them apart), and pre-increment, post-increment, and decrement are all expressions that can be statements.

a = b;                // assignmentw.setSize(200,100);   // method invocationnew WarningWindow(f); // instance creation++i;                  // pre-increment

An expression statement is executed by evaluating the expression.

If the expression is an instance creation, you usually save a reference to ...

Get Just Java™ 2 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.