Array Tutorial

From Progzoo
Revision as of 20:34, 10 December 2008 by Andr3w (talk | contribs)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

An array is a list of values. Using an array you can have a whole load of values in one variable.

Array x

The numbers 0, 1, 2, 3, 4 are the indexes, the five strings "zero", "one", "two", "three", "four" are the values.

You can access elements of the array using the square bracket notation:

String s = x[2];

You can change and element similarly:

x[1] = "ONE";

You can find the number of elements with the length method:

int len = x.length;