```int[][] myArray = { {8,1,2,2,9}, {1,9,4,0,3}, {0,3,0,0,7} };
```

What is the value `myArray` ? 4

(Remember that array indexes start at 0 for both rows and columns.)

# Different Numbers of Cells per Row

Each row of a 2D array may have a different number of cells. In the following example, the array `uneven` has

• 3 cells in its first row,
• 2 in its second row,
• and 5 in its last row.

An array element has to exist to be used in a program. If a program refers to an element that does not exist, bounds checking will catch the error (as the program runs) and generate an exception (which will usually halt your program.)

```class UnevenExample
{
public static void main( String[] arg )
{
// declare and construct a 2D array
int[][] uneven =
{ { 1, 9, 4 },
{ 0, 2},
{ 0, 1, 2, 3, 4 } };

System.out.println("uneven is ", + uneven ) ; // OK
System.out.println("uneven is ", + uneven ) ; // OK
System.out.println("uneven is ", + uneven ) ; // WRONG!

uneven = 97;  // OK
uneven = 97;  // WRONG!

int val = uneven ;  // OK
int sum = uneven ;  // WRONG!
}
}
```

Making an assignment to an element that does not exist is an error. It will not create room in the array for the element.

### QUESTION 8:

Which of the following are correct?

• uneven[ 0 ][ 2 ]
• uneven[ 1 ][ 1 ]
• uneven[ 2 ][ 5 ]
• uneven[ 3 ][ 0 ]