EXPRESSIONS
Simple Assignment Operator
=
15.25.1
15.25 Assignment Operators
There are 12
assignment operators
; all are syntactically right associative (they
group right to left). Thus,
a=b=c
means
a=(b=c)
, which assigns the value of
c
to
b
and then assigns the value of
b
to
a
.
AssignmentExpression:
ConditionalExpression
Assignment
Assignment:
LeftHandSide AssignmentOperator AssignmentExpression
LeftHandSide:
ExpressionName
FieldAccess
ArrayAccess
AssignmentOperator: one of
= *= /= %= += = <<= >>= >>>= &= ^= |=
The result of the first operand of an assignment operator must be a variable, or
a compile time error occurs. This operand may be a named variable, such as a
local variable or a field of the current object or class, or it may be a computed vari
able, as can result from a field access ( 15.10) or an array access ( 15.12). The
type of the assignment expression is the type of the variable.
At run time, the result of the assignment expression is the value of the variable
after the assignment has occurred. The result of an assignment expression is not
itself a variable.
A variable that is declared
final
cannot be assigned to, because when an
access of a
final
variable is used as an expression, the result is a value, not a
variable, and so it cannot be used as the operand of an assignment operator.
15.25.1 Simple Assignment Operator
=
A compile time error occurs if the type of the right hand operand cannot be con
verted to the type of the variable by assignment conversion ( 5.2).
At run time, the expression is evaluated in one of two ways. If the left hand
operand expression is not an array access expression, then three steps are
required:
First, the left hand operand is evaluated to produce a variable. If this evalua
tion completes abruptly, then the assignment expression completes abruptly
369
footer
Our partners:
PHP: Hypertext Preprocessor Best Web Hosting
Java Web Hosting
Inexpensive Web Hosting
Jsp Web Hosting
Cheapest Web Hosting
Jsp Hosting
Cheap Hosting
Visionwebhosting.net Business web hosting division of Web
Design Plus. All rights reserved