CVGalleryGamesPreviewRandomJavaSiteWeb
Site updates
Testing New System now...

Arrays

If a variable is a "box" that can be used to store one piece of data, than an array is a series of boxes, numbered 0 to (n-1), where n is the number of elements in a dimension. An array has one or more of these dimensions. To store a list of ten names, a one dimensional array of 10 Strings would be used. To store the status of a game of chess, an 8x8 array would be used, possibly of a custom class.

To find the number of elements in an array, use the length field.

int[] dave = new int[15];
System.out.println("The array dave can hold " + dave.length + "items of data");

If you want to copy an array, use the clone method

int ia1[] = { 1, 2 };
int ia2[] = (int[])ia1.clone();
--- won't work String[] selectorTypes = new String["FixedValueControl", "RandomValueControl"];
Download arraysize.java
Download arraysize.class
NOTE: The Java section is mostly in maintenence mode. I don't have time to work on it right now. Errors will be corrected if pointed out, but they are not actively being searched for. Newer site features, like alternate stylesheets, may cause problems with these pages.