Java Reference
In-Depth Information
type array-name [ ] = { val1, val2, val3 , …, valN };
Here, the initial values are specified by val1 through valN . They are assigned in sequence,
left to right, in index order. Java automatically allocates an array large enough to hold the
initializers that you specify. There is no need to explicitly use the new operator. For ex-
ample, here is a better way to write the MinMax program:
Array boundaries are strictly enforced in Java; it is a run-time error to overrun or under-
run the end of an array. If you want to confirm this for yourself, try the following program
that purposely overruns an array:
Search WWH ::




Custom Search