Home Articles FAQs XREF Games Software Instant Books About Feedback Search Site-Map
irt.org logo

Q4019 How do I create and use multidimensional arrays in Java?

irt.org | Knowledge Base | Java | Q4019 [ previous next ]

Q4019 How do I create and use multidimensional arrays in Java?

In Java, Multi dimensional arrays are actually arrays of arrays, these act and look like regular multidimentional array. To declare a multidimentional array variable each additional index is specified by a set of square brackets For example the following declares a two dimensional array called twoD

int twoD[ ][ ]= new int[4][5];

The left index determines the row and the right index determines the column, to use this you can refer to a particular value by specifying the indices like

System.out.print(twoD[4][5]);

which will print the integer in the 4th row 5th col.

Feedback on 'Q4019 How do I create and use multidimensional arrays in Java?'


Provide feedback ...
AddThis Social Bookmark Button

Provide feedback ... AddThis Social Bookmark Button


Last Updated: 6th July 2009. Maintained by: Martin Webb
irt.org liability, trademark, document use, privacy statement and software licensing rules apply.
Copyright © 1996-2009 irt.org, All Rights Reserved.