2D-array
2D-array
An array in Java is a collection of similar data types stored in contiguous memory locations.
It is used to store multiple values in a single variable, instead of declaring separate variables for each
value.
2. Indexed: Array elements are accessed using indices (starting from 0).
4. Stored in Contiguous Memory: Elements are stored one after another in memory.
6. Random Access: You can directly access any element using its index
3. Define 2D Array.
A 2D array is an array of arrays — also called a matrix or table, with rows and columns.
It is used to represent data in tabular form.
Declaration of a 2D Array:
int[][] matrix = {
{1, 2, 3},
{4, 5, 6},
{7, 8, 9}
};