Expression
An expression is a piece of source code that produces a value at runtime.
Related concepts: EvaluationValue
Closest Wikipedia entry: Expression (computer science) — In computer science, an expression is a syntactic entity in a programming language that may be evaluated to determine its value. It is a combination of one or more constants, variables, functions, and operators that the programming language interprets (according to its particular rules of precedence and of association) and computes to produce ("to return", in a stateful environment) another value. This process, for mathematical expressions, is called evaluation.
Misconceptions about Expression51 documented Misconceptions
Check YourselfArithmeticPlusPrecedes
Addition has higher precedence than string concatenationAssignCompares
= compares two valuesAssignmentNotExpression
An assignment a=b is not an expressionCannotChainMemberAccesses
Member accesses cannot be chained togetherCannotChainMemberToConstructor
Method calls or field accesses cannot be chained to a constructor invocationChainedMethodsNotCalledFromOutside
Chained methods are all called on the object at the beginning of the chainComparisonWithBooleanLiteral
To test whether an expression is true or false, one must compare it to true or to falseCompositeExpressionsUntyped
Expressions that consist of multiple parts have no typeEqualityOperatorComparesObjectsValues
o==p compares the objects referred to by variables o and pEqualsComparesReferences
o.equals(p) compares the references stored in the variables o and pExpressionAssigns
An expression that reads a variable also updates its value after the evaluationExpressionsDynamicallyTyped
One has to evaluate an expression to determine its typeInlineCallInExpressionTree
The expression tree of an expression involving a call inlines the call's computation of the returned valueInlineVariableInExpressionTree
The expression tree of an expression involving a variable inlines the variable's definitionLargeIntegerLong
Large integer numbers have type longLiteralNoExpression
A literal is not an expressionMapToBooleanWithConditionalOperator
To map a boolean expression to a boolean, a conditional operator is necessaryNoAtomicExpression
Expressions must consist of more than one pieceNoShortCircuit
&& and || always evaluate both operandsObjectsMustBeNamed
A variable is needed to instantiate an objectOutsideInMethodNesting
Nested method calls are invoked outside inParenthesesOnlyIfArgument
() are optional for method calls without argumentsRightToLeftChaining
Chained accesses are invoked from right to leftStringPlusStringifiesExpression
String concatenation stringifies non-String operand expressionsTargetTyping
The type of a numerical expression depends on the type expected by the surrounding contextThisChildInCallExpression
Instance method or constructor call nodes in expression trees have a child labeled "this"ThisNoExpression
The name this is not an expressionVariablesHoldExpressions
= stores an expression in a variable