Subscribe

RSS Feed (xml)

Powered By

Skin Design:
Free Blogger Skins

Powered by Blogger

Monday, November 19, 2007

java array Subscripts - Accessing elements of the array

Integers Selecting a particular position in an array is done by specifying an integer value.
enums Enum values may also be used in index an array.
Square bracketsSubscripts are written after an array variable, enclosed in square brackets.
scores[5] = 86;   // Assigns the value 86 as the 5th value.
scores[ss]++; // Increments the score of element whose number is in ss.
Start at 0 The first subscript value is zero, not one.
Bounds check ArrayIndexOutOfBoundsException is thrown if subscripts are out of the legal range.
Names When a subscript has no meaning, it's common to use i, j, k. Otherwise use a descriptive name.

No comments:

Post a Comment

Archives