1. Home
  2. Computing & Technology
  3. Java
photo of Paul Leahy
Paul's Java Blog

By Paul Leahy, About.com Guide to Java

Java Term of the Week: Expression Statement

Saturday July 11, 2009

Some expressions can be used as statements by simply adding a semicolon. They are known as expression statements. When these statements are executed the value of the expression is evaluated.

The expressions that can be made into statements:

  • use the increment (++) and decrement (--) unary operators.
  • assign values to variables.
  • call object methods.
  • create objects.

For example, the following are expression statements:

//assigning a value
number = 42;

//using the increment operator
number++;

//using the decrement operator
--number;

//calling a method
System.out.println("Is " + number + " the answer to the Ultimate Question of Life, the Universe and Everything?");

//creating an object
Universe realityOne = new Universe(42);
Comments

No comments yet. Leave a Comment

Leave a Comment

Line and paragraph breaks are automatic. Some HTML allowed: <a href="" title="">, <b>, <i>, <strike>

Discuss
Community Forum
Explore Java
About.com Special Features

Stay connected and entertained with reviews on tips on the latest HDTVs, cellphones and more. More >

Easy ways to connect two computers for networking purposes. More >

  1. Home
  2. Computing & Technology
  3. Java

©2009 About.com, a part of The New York Times Company.

All rights reserved.