Double Dimensional Arrays Flashcards
What is a 2D Array?
It is an array of arrays and it stores data in rows and columns (tabular format).
Elements can be accessed through using two indices which is?
row index and column index.
What is the other name of 2D dimensional?
multidimensional arrays
What is a data structure commonly used in mathematics to represent matrices and complex data structures?
2D Array
When a 2D Array is created, Java first creates a 1D array that contains _________ (pointers) to other 1D arrays, which represent the ___ of the 2D array.
references, rows
How are the rows of a 2D array stored in Java?
Each row in a 2D array is stored as a separate 1D array, and the main array contains pointers to these individual row arrays.
How many indices are required to access an element in a 2D array in Java?
A 2D array in Java requires two indices:
* One for the row
* One for the column
How do you initialize a 2D array in Java with specific values?
A 2D array can be initialized using curly braces {} with nested arrays:
int[][] matrix = {
{1, 2, 3},
{4, 5, 6},
{7, 8, 9}
};
How do you declare a 2D array in Java?
Declared using the following syntax:
dataType[][] arrayName;
What are the ways to initialize a 2D Array
- Static Initialization
- Dynamic Initialization
Set the size first, then assign values later
Dynamic Initialization
Assign values directly during declaration.
Static Initialization
What happens when only the number of rows is specified while declaring a 2D array in Java?
The columns remain uninitialized, creating a jagged array where each row can have a different number of columns.
A ____ array is useful for storing ____________ , such as words of different lengths, lists of varying sizes, or ____________.
jagged, flexible data structures, irregularly shaped matrices
Why must the number of rows be specified first when creating a 2D array in Java?
In Java, a 2D array is an array of 1D arrays, so the number of rows must be specified first to allocate space for row references before defining column sizes.
What happens when a 2D array is declared without initializing rows or columns in Java?
It only creates a reference without allocating memory. The array must be initialized before use.
How do you declare a 2D array in Java without initializing its size?
You can declare a 2D array like this:
int[][] matrix;
This is capable of storing images, text, and other types of data, and is useful for data analysis and visualization?
2D Array
Specify the number of rows but leave columns uninitialized.
Double-Dimensional Array with Only Rows Initialized
What is a jagged Array?
is a 2D array where each row can have a different number of columns.
You must define rows first because a 2D array is an array of arrays.
Double-Dimensional Array with Only Columns Initialized
This type of array can declare a 2D array without initializing rows or columns.
Double-Dimensional Array with No Rows or Columns Initialized
This is just a reference; no memory is allocated yet and must be initialize before use.
Double-Dimensional Array with No Rows or Columns Initialized
This type of array can declare a 2D array without initializing rows or columns.
Double-Dimensional Array with No Rows or Columns Initialized