## 声明二维数组

```ticketInfo = new int [2][3];
seatingChart = new String [3][2];```

## 为数组赋值

```public class Test
{
public static void main(String[] args)
{
// declare arrays
int[][] ticketInfo;
String[][] seatingChart;

// create arrays
ticketInfo = new int [2][3];
seatingChart =  new String [3][2];

// initialize the array elements
ticketInfo[0][0] = 15;
ticketInfo[0][1] = 10;
ticketInfo[0][2] = 15;
ticketInfo[1][0] = 25;
ticketInfo[1][1] = 20;
ticketInfo[1][2] = 25;
seatingChart[0][0] = "Jamal";
seatingChart[0][1] = "Maria";
seatingChart[1][0] = "Jacob";
seatingChart[1][1] = "Suzy";
seatingChart[2][0] = "Emma";
seatingChart[2][1] = "Luke";

// print the contents
System.out.println(ticketInfo);
System.out.println(seatingChart);
}
}```

0:00

Which of the following sets the value for the 3rd row and 2nd column of a 2D array called `nums`?

3

```int[][] ticketInfo = {{25,20,25}, {25,20,25}};
String[][] seatingInfo = {{"Jamal", "Maria"}, {"Jake", "Suzy"}, {"Emma", "Luke"}};```

## 读取数组元素

```int[][] ticketInfo = {{25,20,25}, {25,20,25}};
String[][] seatingInfo = {{"Jamal", "Maria"}, {"Jake", "Suzy"}, {"Emma", "Luke"}};
int value = ticketInfo[1][0];
String name = seatingInfo[0][1];```

What is the value of `name` after the code above executes?

`[0][1]`对应的是第一行第二列的元素。
2