Statements and Expressions

Statements

This is a specialized type of expression. In this form of expression, you are
creating a variable or object, or you are assigning a value to a variable you
previously created.

Example:

int number;
bool truefalse;
number = 5
truefalse = false

 

Note: When assigning a value, use a single equals sign.

Expressions

These are individual lines of Java code. Expressions are ended by semicolons.
Different expressions in a certain order are what essentially make up a program.

Example:

int number;
number = 5;
if (number > 3);
number = number - 1;
println("number has been whittled down to 3");

Next

Home Page | Table of Contents | Introduction | Programming | Extras