Syntax question on Arraylength

Hi, i dont understand this line of code :

for (int y=0; y<myArray[1].length; y++)

myArray has a "[1]" , and my codee has a 2D array, is this saying use the length of the second array ? or does it means something else ?

Bigger image: http://s13.postimg.org/hcg60mpqv/line.png

thanx!line

Answers

  • Answer ✓

    yeah, I think, myArray.length gives the length of the 1st dimension and myArray[1].length of the 2nd dimension.

    useful in a double for-loop

    in theory the single arrays within the first array could be of different lengths, but usually the 2D array is of the same length like in a chess board

Sign In or Register to comment.