EXPRESSIONS
Runtime Evaluation of Array Access
15.12.1
15.12   Array Access Expressions
An array access expression refers to a variable that is a component of an array.
ArrayAccess:
ExpressionName
 [
Expression
 ]
PrimaryNoNewArray
 [
Expression
 ]
An array access expression contains two subexpressions, the
array reference
expression
 (before the left bracket) and the
index expression
 (within the brackets).
Note that the array reference expression may be a name or any primary expression
that is not an array creation expression ( 15.9).
The type of the array reference expression must be an array type (call it
T
[]
,
an array whose components are of type
T
) or a compile time error results. Then
the type of the array access expression is
T
.
The index expression undergoes unary numeric promotion ( 5.6.1); the pro 
moted type must be
int
.
The result of an array reference is a variable of type
T
, namely the variable
within the array selected by the value of the index expression. This resulting vari 
able, which is a component of the array, is never considered
final
, even if the
array reference was obtained from a
final
 variable.
15.12.1   Runtime Evaluation of Array Access
An array access expression is evaluated using the following procedure:
First, the array reference expression is evaluated. If this evaluation completes
abruptly, then the array access completes abruptly for the same reason and the
index expression is not evaluated.
Otherwise, the index expression is evaluated. If this evaluation completes
abruptly, then the array access completes abruptly for the same reason.
Otherwise, if the value of the array reference expression is
null
, then a
NullPointerException
is thrown.
Otherwise, the value of the array reference expression indeed refers to an
array. If the value of the index expression is less than zero, or greater than or
equal to the array's length, then an
IndexOutOfBoundsException
 is thrown.
Otherwise, the result of the array reference is the variable of type
T
, within the
array, selected by the value of the index expression. (Note that this resulting
variable, which is a component of the array, is never considered
final
, even
if the array reference expression is a
final
 variable.)
341






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