Java Term of the Week: Expression Statement
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);


No comments yet. Leave a Comment