(Review: ) Is the following a correct expression?
13 * 6 -
No.
The literals (the integers) and the operators are out of order in the
above incorrect expression.
(One legal arrangement is 13 * -6
An expression is a combination of literals, operators, variables, and parentheses used to calculate a value.
Of course, the parts of an expression must be arranged correctly. The syntax of Java (or any programming language) describes the correct arrangements. The details of this will be left to another course (or your on-line documentation, if you care to dig through it.) The rules for correct Java expressions are about the same as for algebra.
We need to talk about operators and operands. You already know what an operator is (a symbol +, -, *, / that calls for an arithmetic operation.)
An operand is a value that is acted upon by an operator.
For example, in 13 - 5
the 13 and the 5 are the operands and
the - is the operator.
Examine the following expressions.
Assume that each variable has already been correctly declared.