[ Contact ] [ Links ] [ Previous : 8 / 29 : Java Data Types ] [ Up ] [ Next : 10 / 29 : Java Objects ]

Java Arrays

Java arrays fall between a primitive data type and an object

Properties of Java arrays:

byte buffer[];		// array declaration (buffer = null)
buffer = new byte[1024];	// array creation (contents initialised to zeros)
int table[] = new int[10];	// declaration and creation combined
   
int sqrs[] = {0, 1, 4, 9, 16, 25, 36, 49, 64, 81 }; // with an initializer
buffer[5] = sqrs[sqrs.length-1]; // array references
   
int triangle[][] = new int[3][];	// 2D Arrays do not have to be matrix
triangle[0] = new int[3];
triangle[1] = new int[2];
triangle[2] = new int[1];
 

See the "Links" link above to find out the sources of the proposed informations
Pascal Vuylsteker / eScience / Computer Science / ANU
Last modified: 20/4/2004
TOC - Print
Send your comments at :
<Hugh.Fisher@anu.edu.au>