15.9.1
Run time Evaluation of Array Creation Expressions
EXPRESSIONS
DimExprs:
DimExpr
DimExprs DimExpr
DimExpr:
[
Expression
]
Dims:
[ ]
Dims
[ ]
An array creation expression creates an object that is a new array whose ele
ments are of the type specified by the
PrimitiveType
or
TypeName
. The
TypeName
may name any reference type, even an
abstract
class type ( 8.1.2.1) or an inter
face type ( 9).
The type of the creation expression is an array type that can denoted by a copy
of the creation expression from which the
new
keyword and every
DimExpr
expression have been deleted; for example, the type of the creation expression:
new double[3][3][]
is:
double[][][]
The type of each dimension expression
DimExpr
must be an integral type, or a
compile time error occurs. Each expression undergoes unary numeric promotion
( 5.6.1). The promoted type must be
int
, or a compile time error occurs; this
means, specifically, that the type of a dimension expression must not be
long
.
15.9.1 Run time Evaluation of Array Creation Expressions
At run time, evaluation of an array creation expression behaves as follows.
First, the dimension expressions are evaluated, left to right. If any of the
expression evaluations completes abruptly, the expressions to the right of it are not
evaluated.
Next, the values of the dimension expressions are checked. If the value of any
DimExpr
expression is less than zero, then an
NegativeArraySizeException
is
thrown.
Next, space is allocated for the new array. If there is insufficient space to allo
cate the array, evaluation of the array creation expression completes abruptly by
throwing an
OutOfMemoryError
.
316
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