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 Expression
51 documented Misconceptions

Check Yourself
Misconception
ArithmeticPlusPrecedes
Addition has higher precedence than string concatenation
Misconception
AssignCompares
= compares two values
Misconception
AssignmentNotExpression
An assignment a=b is not an expression
Misconception
CannotChainMemberAccesses
Member accesses cannot be chained together
Misconception
CannotChainMemberToConstructor
Method calls or field accesses cannot be chained to a constructor invocation
Misconception
ChainedMethodsNotCalledFromOutside
Chained methods are all called on the object at the beginning of the chain
Misconception
ComparisonWithBooleanLiteral
To test whether an expression is true or false, one must compare it to true or to false
Misconception
CompositeExpressionsUntyped
Expressions that consist of multiple parts have no type
Misconception
EqualityOperatorComparesObjectsValues
o==p compares the objects referred to by variables o and p
Misconception
EqualsComparesReferences
o.equals(p) compares the references stored in the variables o and p
Misconception
ExpressionAssigns
An expression that reads a variable also updates its value after the evaluation
Misconception
ExpressionsDynamicallyTyped
One has to evaluate an expression to determine its type
Misconception
InlineCallInExpressionTree
The expression tree of an expression involving a call inlines the call's computation of the returned value
Misconception
InlineVariableInExpressionTree
The expression tree of an expression involving a variable inlines the variable's definition
Misconception
LargeIntegerLong
Large integer numbers have type long
Misconception
LiteralNoExpression
A literal is not an expression
Misconception
MapToBooleanWithConditionalOperator
To map a boolean expression to a boolean, a conditional operator is necessary
Misconception
NoAtomicExpression
Expressions must consist of more than one piece
Misconception
NoShortCircuit
&& and || always evaluate both operands
Misconception
ObjectsMustBeNamed
A variable is needed to instantiate an object
Misconception
OutsideInMethodNesting
Nested method calls are invoked outside in
Misconception
ParenthesesOnlyIfArgument
() are optional for method calls without arguments
Misconception
RightToLeftChaining
Chained accesses are invoked from right to left
Misconception
StringPlusStringifiesExpression
String concatenation stringifies non-String operand expressions
Misconception
TargetTyping
The type of a numerical expression depends on the type expected by the surrounding context
Misconception
ThisChildInCallExpression
Instance method or constructor call nodes in expression trees have a child labeled "this"
Misconception
ThisNoExpression
The name this is not an expression
Misconception
VariablesHoldExpressions
= stores an expression in a variable

Stay up-to-date

Follow us on  twitter to hear about new misconceptions.