O'Reilly logo

Java 2™ Programmer Exam Cram™ 2 (Exam CX-310-035) by Marcus Green, Bill Brogden

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Array Initialization

An array in Java is a type of object that can contain a number of variables. These variables can be referenced only by the array index—a nonnegative integer. The first element in an array has an index of 0.

All of these contained variables, or elements, must be the same type, which is the type of the array. Every array has an associated length variable, established when the array is created, which you can access directly. If you try to address an element with an index that is outside the range of the array, an exception is generated. Java arrays are one dimensional, but an array can contain other arrays, which gives the effect of multiple dimensions.

You can have arrays of any of the Java primitives or reference variables. ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required