Q:

Creating and Using arrays

I am new to the concept of arrays in java, and as part of an assignment, I am required to create a 10 row by 3 column integer array and populate it with a for loop. I have the following.
  public class arrays{

  int arr[][][] = new int [10][10][10];

    for(int i=0;i<arr.length;++i)
    {
        for(int j=0;j<arr[i].length;++j)
        {
            System.out.print(arr[i][j] + " ");
        }
        System.out.println();
    }
} 

am I on the right track?

A:

You are actually declaring a 3-dimensional array.
You should instead be declaring int[][] arr = new int[10][3];.
You can then assign values as follows: arr[i][j] = 42;
Note also that when instantiated, the initial values in the array are 0.

