Home Java SCJP SCWCD Servlet Submit News Contact Us Site Map


Over 500 magazines for free (including Oracle Magazine)!

Yes all of them are FREE. You can subscribe to ALL of them.
Click here to apply today!

Home > Java > Java Articles

Accessing elements of an array

Individual elements of an array can be accessed by specifying index with [] operator, with the following syntax.

arrayName[<index>]

Here index can be any expression, which evaluates to non negative int value. Array index always starts at 0 and ends at arrayName.length – 1. Array index is automatically checked to ensure that it is well within the bounds. If index is less than 0 or grater than arrayName.length, an ArrayIndexOutOfBoundException is thrown.

Note: [] operator is not used when manipulating the array reference. For example, when array reference is passed to another method.

 

<<Array Initialization

Multidimensional Array >>

 

Home Java SCJP SCWCD Servlet Site map