I am in the process of learning Java and am very confused on multidimensional arrays. When I say this I don't mean the array syntax but more so the logic of using arrays with for statements. What I am wondering is how do I incorporate arrays into for statements correctly and what does all of the code in play do, and why is it there. Here is some code I have been working on (based off a tutorial) and was wondering if someone could fully explain everything that is going on.
package tutorial;
public class apples {
public static void taco(String[] args) {
int firstarray[][]={{8,9,10,11},{12,13,14,15}};
int secondarray[][]={{30,31,32,33},{43},{4,5,6}};
System.out.println("This is the first array");
display(firstarray);
System.out.println("This is the second array");
display(secondarray);
}
public static void display(int x[][]) {
for (int row=0;row<x.length;row++) {
for (int column=0;column<x[row].length;column++) {
System.out.println(x[row][column]+"\t");
}
System.out.println();
}
}
So what I don't understand is the entire
public static void display(int x[][]) {
for (int row=0;row<x.length;row++) {
for (int column=0;column<x[row].length;column++) {
System.out.println(x[row][column]+"\t");
If someone could explain that in more depth that would be great. I get for statements and arrays in general, im just confused with how this works.