Multi-Dimensional
Lesson 13 of 16 in Coddy's Strings and Arrays in Java course.
A multi-dimensional array is an array of arrays.
To create a two-dimensional array, add each array within its own set of curly braces:
int[][] myNumbers = {{1, 2, 3, 4}, {5, 6, 7}};An example of element access:
System.out.println(myNumbers[1][2]); // Outputs 7And modifying elements:
myNumbers[1][2] = 5;
System.out.println(myNumbers[1][2]); // Outputs 5This lesson includes a short quiz. Start the lesson to answer it and track your progress.
This lesson includes a short quiz. Start the lesson to answer it and track your progress.
Try it yourself
This lesson doesn't include a code challenge.