15.25.2
Compound Assignment Operators
EXPRESSIONS
value of this component is saved and then the right hand operand is evaluated.
If this evaluation completes abruptly, then the assignment expression com 
pletes abruptly for the same reason and no assignment occurs. (For a simple
assignment operator, the evaluation of the right hand operand occurs before
the checks of the array reference subexpression and the index subexpression,
but for a compound assignment operator, the evaluation of the right hand
operand occurs after these checks.)
Otherwise, consider the array component selected in the previous step, whose
value was saved. This component is a variable; call its type
S
. Also, let
T
 be
the type of the left hand operand of the assignment operator as determined at
compile time.
N
If
T
 is a primitive type, then
S
 is necessarily the same as
T
.
O
The saved value of the array component and the value of the right hand
operand are used to perform the binary operation indicated by the com 
pound assignment operator. If this operation completes abruptly (the only
possibility is an integer division by zero see  15.16.2), then the assign 
ment expression completes abruptly for the same reason and no assign 
ment occurs.
O
Otherwise, the result of the binary operation is converted to the type of the
array component and the result of the conversion is stored into the array
component.
N
If
T
 is a reference type, then it must be
String
. Because class
String
 is a
final
 class,
S
 must also be
String
. Therefore the run time check that is
sometimes required for the simple assignment operator is never required for
a compound assignment operator.
O
The saved value of the array component and the value of the right hand
operand are used to perform the binary operation (string concatenation)
indicated by the compound assignment operator (which is necessarily
+=
). If this operation completes abruptly, then the assignment expression
completes abruptly for the same reason and no assignment occurs.
O
Otherwise, the
String
 result of the binary operation is stored into the
array component.
The rules for compound assignment to an array component are illustrated by the
following example program:
class ArrayReferenceThrow extends RuntimeException { }
class IndexThrow extends RuntimeException { }
376






footer




 

 

 

 

 Home | About Us | Network | Services | Support | FAQ | Control Panel | Order Online | Sitemap | Contact

java hosting

 

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