Home Articles FAQs XREF Games Software Instant Books BBS About FOLDOC RFCs Feedback Sitemap
irt.Org
#

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

You are here: irt.org | FAQ | Java | Q4019 [ previous next ]

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?'

©2018 Martin Webb