Accessing an Array

From Progzoo
Jump to: navigation, search

You access an array using the square bracket notation.

The first element of array x is x[0]

You can initialise the array to a specific list of values:


[Font] [Default] [Show] [Resize] [History] [Profile]

The last element of array x is x[x.length-1]

You can initialise the array to a specific list of values:


[Font] [Default] [Show] [Resize] [History] [Profile]

Out of Bounds

If you try to read past the end of an array an exception java.lang.ArrayIndexOutOfBoundsException is raised.


[Font] [Default] [Show] [Resize] [History] [Profile]