Mar 17, 2025
Direct Initialization:
int[][].int[][] lotteryCard = {
{20, 15, 7},
{8, 7, 19},
{7, 13, 14}
};
Using 'new' Keyword:
int[][] lotteryCard2 = new int[3][3];
lotteryCard2[0][0] = 20;
lotteryCard2[0][1] = 15;
// Continue assigning...
array[row][column].lotteryCard[0][0] retrieves the value 20.Single Element:
System.out.println(lotteryCard[0][0]); prints 20.Using Loops for Multiple Elements:
for (int i = 0; i < 3; i++) {
System.out.println(lotteryCard[i][i]);
}
for (int i = 0; i < 3; i++) {
for (int j = 0; j < 3; j++) {
System.out.print(lotteryCard[i][j] + " ");
}
System.out.println();
}