Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class MultidimensionArray {
- public static void main(String[] args) {
- int[][] multiDimensionalArray = new int[3][2];
- for (int i = 0; i < multiDimensionalArray.length; i++) {
- //i is looping through the first sub-array
- for (int j = 0; j < multiDimensionalArray[i].length; i++) {
- //j loops through and finds number of elements in sub array
- System.out.print(multiDimensionalArray[i][j] + " ");
- //inner loop prints the results, and when it completes, the outer loop starts again to loop over the second element in sub array
- System.out.println();
- //new line
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement