22.03 Arrays

Arrays

Overview

Arrays are used to store multiple values of the same type in a single variable.

Topics

Examples

int[] numbers = {1, 2, 3, 4, 5};
for (int num : numbers) {
    System.out.println(num);
}

int[][] matrix = {
    {1, 2, 3},
    {4, 5, 6}
};
System.out.println(matrix[0][1]); // Output: 2

Tags

#java #arrays #multidimensionalarrays #iteration