zuai-logo

2D Array

Listen to this study note

AP Computer Science A Study Guide

2D Arrays

Quick Fact

šŸ’” A 2D array in Java is essentially an array of arrays, forming a table-like structure with rows and columns.

Declaration and Initialization

  • Declaration: To declare a 2D array, you specify the data type, followed by two sets of square brackets (one for rows, one for columns), and the array name.

java int[][] matrix; // Declar...

Question 1 of 6

Alright, let's get started! šŸš€ Which of the following is the correct way to declare a 2D array of integers in Java?

int array[][];

int[][] array;

array int[][];

int[ , ] array;