NoAtomicExpression

Incorrect

Expressions must consist of more than one piece

Correct

A single piece, like a literal or name, also is an expression

Correction
Here is what's right.

Even 1 is an expression. The same applies to a, or m(), or new Point(). There is no need for an operator. Of course an expression can involve operators, thus 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 1, which represents the literal 1, which is an expression (that always evaluates to the value 1).

Language

Java

Concepts

Expressible In

Related Misconceptions

Other Languages

Literature References

The following papers directly or indirectly provide qualitative or quantitative evidence related to this misconception.

Stay up-to-date

Follow us on  twitter to hear about new misconceptions.