int anIndex = 1;
int [][] anArray = {{1, 2}, {3, 4, 5}, {6, 7, 8, 9}};
System.out.println("Number: " + anArray[anIndex++][anIndex++] + ".");
prints out "Number: 5." That's anArray[1][2]; anIndex is incremented after each index, so it ends up at 3 by the end of the code fragment.
No comments:
Post a Comment