You can have arrays in Java, but you can't have multi-dimensional arrays. What appears to be a 2-directional array is not that; it is actually a 1-dimensional array of 1-dimensional arrays. What appears to be a 3-dimensional array is not that, it is a 1-dimensional array of 1-dimensional arrays of 1-dimenisonal arrays.
That means you can write and myArray or myJaggedArray then act as ordinary int arrays.
The answer to the question you meant to ask and didn't is (if I remember correctly) 255 in Java.
Originally posted by Campbell Ritchie: The answer to the question you meant to ask and didn't is (if I remember correctly) 255 in Java.
Perhaps you could tell us what the quetstion he meant to ask and didn't is, because I'm not sure what you're trying to answer here. I'm not aware of any size restriction that limits the number of elements in an array to 255, nor can I figure out any reason why you could not have a tree of greater depth than 255 made with arrays. Did I miss something here?
My answer to the original question would be this: You can have as many dimensions in an array as you like, and as many indices in each dimension as you would like, provided your system has the memory available for it.
I don't think this is specified in the JLS (though it should be), but it's in the JVMS: "The number of dimensions in an array is limited to 255 by the size of the dimensions opcode of the multianewarray instruction and by the constraints imposed on the multianewarray, anewarray, and newarray instructions by �4.8.2."