public class Test
{
public static void main(String args[])
{
final int NUM_row = 4;
final int Num_columns=6;
int[][] numbers = new int[NUM_row][Num_columns];
Random randomNumbers = new Random();
int row, columns;
final int PowerNUM_row = 4;
final int PowerNum_columns=5;
int[][] Powernumbers = new int[PowerNUM_row][PowerNum_columns];
Random PowerrandomNumbers = new Random();
int Powerrow, Powercolumns=0 ;
for (Powerrow = 0; Powerrow < 3; Powerrow++)
for (Powercolumns = 0; Powercolumns < 1; Powercolumns++)
Powernumbers[Powerrow][Powercolumns] = PowerrandomNumbers.nextInt(12);
/* now that the loop is over, Powerrow = 3, Powercolumns = 1 */
for (row = 0; row < 3; row++)
for (columns = 0; columns < 5; columns++)
numbers[row][columns] = randomNumbers.nextInt(49);
System.out.printf("Power Ball Ticket: \n\n");
for (row = 0; row < 1; row++)
{
for (columns = 0; columns < 5; columns++)
{
System.out.printf("%d ",numbers[row][columns]);
}
/*
Powerrow, Powercolumns not reset, so this prints Powernumbers[3][1]
which is never modified after initialization, and therefore 0
*/
System.out.printf("Power Ball: %d", Powernumbers[Powerrow][Powercolumns]);
System.out.println();
}
}
}
Hopefully that clears it up for you. I suggest you write cleaner code in the future where your logic is easier to follow. Your loops when generating the Powernumbers modify Powerrow and Powercolumns until they reach 3 and 1, respectively. Since Powernumbers[3][1] is never modified at any intermittent point, the value, when printed, will be that default from initialization i.e. 0.