I\'ve read Oracle\'s expressions tutorial and couldn\'t understand this.
It is well known that the following line of code is valid Java syntax:
new O
The rule is in the Java Language Specification:
Certain kinds of expressions may be used as statements by following them with semicolons.
ExpressionStatement:
- StatementExpression ;
StatementExpression:
- Assignment
- PreIncrementExpression
- PreDecrementExpression
- PostIncrementExpression
- PostDecrementExpression
- MethodInvocation
- ClassInstanceCreationExpression
You see that a constructor invocation is a statement. But a String literal or mathematical expression is not.