Limited access

Upgrade to access all content for this subject

The following code fills an array with $10$ integers using a for loop. A second loop is then used to print the values in the array:

int[] values = new int[10];

for(int i = 0; i < values.length; i++) {
   int index = values.length - 1 - i;
   if(index % 2 == 0)
      values[index] = i;
   else
      values[index] = index;
}

for(int j = 0; j < values.length; j++) {
   System.out.print(values[j]);
}
Select an assignment template