An expression must involve multiple operands combined with operators.
An individual literal, like
19, or a variable, like
or a method call, like
m(), or a constructor invocation, like
is not an expression.
Expressions must consist of more than one piece
A single piece, like a literal or name, also is an expression
CorrectionHere is what's right.
1 is an expression.
The same applies to
There is no need for an operator.
Of course an expression can involve operators,
1 + 3 or
1 + a are expressions, too.
Explain by Referring to the Definition
An expression is a piece of code that evaluates to a value. Anything that evaluates to a value is an expression. A single variable name also evaluates to a value, so does a method call (with a non-void return type), a constructor call, or even a literal (a value that stands for itself).
Explain with Expression Trees
The following tree represents the expression
val + 1:
The entire tree, rooted in
+, is an expression.
Moreover, the subtree rooted in
val, which consists of a single node, also is an expression.
The same applies to the subtree rooted in
which represents the literal
which is an expression (that always evaluates to the value 1).