Unit 8: 2D Array Flashcards

1
Q

A 2D array is ___.

A

an array of arrays

note: can put arrays in there or put names of already declared arrays

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

declaring a 2D array (2 ways):

A

dataType[] arrayName = new dataType[row][column]

OR int[] arrayName = {{1, 2, 3}, {4, 5, 6]]

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

how to find the number of rows and columns

A

rows = array.length
columns = array[0].length
(this is because APCSA only uses rectangular 2D arrays)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

accessing elements in an array

A

arrayName[row][column]

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

setting elements to a value in an array

A

arrayName[row][column] = value;

How well did you know this?
1
Not at all
2
3
4
5
Perfectly