20 October 2010
0 Multidimensional Arrays in Java
Multidimensional Arrays in Java
- Multidimensional arrays are arrays of arrays.
- To declare a multidimensional array variable, specify each additional index using another set of square brackets.
int [][] x;
//x is a reference to an array of int arrays
x = new int[3][4];
/*Create 3 new int arrays, each having 4 elements
x[0] refers to the first int array, x[1] to the second etc
x[0][0] is the first element of the first array
x.length will be 3
x[0].length, x[1].length and x[2].length will be 4 */
//x is a reference to an array of int arrays
x = new int[3][4];
/*Create 3 new int arrays, each having 4 elements
x[0] refers to the first int array, x[1] to the second etc
x[0][0] is the first element of the first array
x.length will be 3
x[0].length, x[1].length and x[2].length will be 4 */
Subscribe to:
Post Comments (Atom)
0 comments:
Please give your valuable comments.