Join
Blogs
Questions
Videos
Tags
Members
Search
 
 
Create your own blog, earn points and get popular!

Accessing Array Elements, Java Array Tutorial

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 >>
No votes yet
Share this

Post new comment