two dimensional arrays Flashcards

1
Q

multidimensional array

A

arrays of arrays

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

how java stores 2-dim arrays

A

array of array references

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

create a rectangular 2-dim array (primitive)

A

char[][]a=new char[5][8];

break down:
> char is the type (an array of arrays of characters)
> a is the name
> 5 is the length of the array of array references
> 8 is the length of the arrays the original array is pointing to

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

what does the heap look like

A

an array of array references that point to individual arrays

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

char[][]a=new char[5][8];

a.length = ?

A
a.length = 5
a[1].length = 8
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

iterate row by row

A
for(introw = 0; row < a.length; row++) { 
for(intcol = 0; col < a[row].length; col++) {
a[row][col] = ‘ ’;
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

ragged array

A

a 2-dim array with arrays of different sizes

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

crate a ragged 2-dim array

A

char[][]a=new char[3][];
a[0]=new char[8];
a[1]=new char[0];
a[2]=null;

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

1-dim initializer

A

int[ ] quizScoresOne= { 90, 82, 75, 66 };

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

create a ragged 2-dim array (primitive)

A

char[][]a=new char[3][];
a[0]=new char[8];
a[1]=new char[0];
a[2]=null;

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

2-dim initializer

A

int[ ][ ] quizScoresTwo= { { 90, 82, 75, 66 }, { 85 }, { 45, 77, 99 } };

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

create a 2-dim array (objects, nonprimative)

A

ObjectType [][] var=new ObjectType[MAXROW][MAXCOL];

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