これは遅いかもしれませんが、このメソッドはあなたが求めることを完璧な方法で行います。要素を「テーブルのような」スタイルで表示することもできます。
public static void display(int x[][]) // So we allow the method to take as input Multidimensional arrays
{
//Here we use 2 loops, the first one is for the rows and the second one inside of the rows is for the columns
for(int rreshti = 0; rreshti < x.length; rreshti++) // Loop for the rows
{
for(int kolona = 0; kolona < x[rreshti].length;kolona++) // Loop for the columns
{
System.out.print(x[rreshti][kolona] + "\t"); // the \t simply spaces out the elements for a clear view
}
System.out.println(); // And this empty outputprint, simply makes sure each row (the groups we wrote in the beggining in seperate {}), is written in a new line, to make it much clear and give it a table-like look
}
}
このメソッドの作成が完了したら、これをメイン メソッドに入れるだけです。
display(*arrayName*); // So we call the method by its name, which can be anything, does not matter, and give that method an input (the Array's name)
ノート。入力として多次元配列を必要とするようにメソッドを作成したため、1 次元配列では機能しません (とにかく意味がありません)。
出典:リンクの説明をここに入力
PS。私の言語を使用して要素/変数に名前を付けたので、少し混乱するかもしれませんが、CBAがそれらを翻訳しました。