Question

I've been having some issues trying to make sense of Java's 2D arrays. I've read about upper and lower bounds, are they equivalent to rows and columns or am I misinterpreting something? Thanks in advance.

Était-ce utile?

La solution

int[][] arr = new int[x][y];

A two dimensional array is essentially an array of arrays. You could think of them as rows and columns, but they're really showing this:

arr = {{0, 1, 2}, {3, 4, 5}, {6, 7, 8}};

Which you can think of as:

0 1 2
3 4 5
6 7 8
Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top