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
2
Q
declaring a 2D array (2 ways):
A
dataType[] arrayName = new dataType[row][column]
OR int[] arrayName = {{1, 2, 3}, {4, 5, 6]]
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)
4
Q
accessing elements in an array
A
arrayName[row][column]
5
Q
setting elements to a value in an array
A
arrayName[row][column] = value;