2D Arrays

4.3(4)
Studied by 179 people
0%Unit 8 Mastery
0%Exam Mastery
Build your Mastery score
multiple choiceMultiple Choice
call kaiCall Kai
Supplemental Materials
Card Sorting

1/9

flashcard set

Earn XP

Last updated 7:07 AM on 2/24/24
Name
Mastery
Learn
Test
Matching
Spaced
Call with Kai

No analytics yet

Send a link to your students to track their progress

10 Terms

1
New cards

2D Arrays

Arrays that have rows and columns, forming a grid-like structure.

2
New cards

Array of Arrays

A 2D array

3
New cards

Rows length

The number of rows in a 2D array, accessed using arrayName.length.

4
New cards

Columns length

The length of the first column in a 2D array, accessed using arrayName[0].length.

5
New cards

Indexes

Positions in a 2D array

6
New cards

Initialize a 2D array by elements

int[][] numbers = {{1,2,3,4},{5,6,7,8}};

This would create the two-dimensional array with first row as array [1, 2, 3, 4] and second row as array [5, 6, 7, 8].

7
New cards

Initialize a 2D array by size

int[][] numbers = new int[2][2];
numbers[0][0] = 0;
//...

This would create the two dimensional array with 2 rows and 2 columns. Then you can set the values of individual elements using the row and column index.

8
New cards

How do you access an element of a 2D array?

Use the row index (r), then the column index (c), as shown.

Example: Access element in second row, first column. This would print “5”.

int[][] numbers = {{1,2,3,4},{5,6,7,8}};
System.out.print(numbers[1][0]);
9
New cards

What index does any array start at?

0

10
New cards

What index does an array end at?

array.length - 1

Explore top notes

note
A1 German Lessons
Updated 263d ago
0.0(0)
note
Chapter 3:Ionic Compounds
Updated 1267d ago
0.0(0)
note
Philosophy Final Exam Review
Updated 1099d ago
0.0(0)
note
Introduction to the Legal System
Updated 587d ago
0.0(0)
note
Biological Molecules
Updated 1039d ago
0.0(0)
note
Practice Final
Updated 527d ago
0.0(0)
note
A1 German Lessons
Updated 263d ago
0.0(0)
note
Chapter 3:Ionic Compounds
Updated 1267d ago
0.0(0)
note
Philosophy Final Exam Review
Updated 1099d ago
0.0(0)
note
Introduction to the Legal System
Updated 587d ago
0.0(0)
note
Biological Molecules
Updated 1039d ago
0.0(0)
note
Practice Final
Updated 527d ago
0.0(0)

Explore top flashcards

flashcards
Science exam Year 8
61
Updated 881d ago
0.0(0)
flashcards
Electromagnetism Physics Vocab
30
Updated 1065d ago
0.0(0)
flashcards
Connect 4, Unit 3
52
Updated 1022d ago
0.0(0)
flashcards
12/14 India + China test
63
Updated 1198d ago
0.0(0)
flashcards
Unit 1 AP GOV
63
Updated 346d ago
0.0(0)
flashcards
Science exam Year 8
61
Updated 881d ago
0.0(0)
flashcards
Electromagnetism Physics Vocab
30
Updated 1065d ago
0.0(0)
flashcards
Connect 4, Unit 3
52
Updated 1022d ago
0.0(0)
flashcards
12/14 India + China test
63
Updated 1198d ago
0.0(0)
flashcards
Unit 1 AP GOV
63
Updated 346d ago
0.0(0)