I was able to create an array of 10 numbers.
Then I was able to allow for input of those 10 number from the keyboard.
When I run the code in intelliJ it does what's asked in terms of displaying the numbers in reverse order, with each number on a new line.
However, when I verify the solution/task through code gym, it does not pass the last two conditions which are:
The program should display 10 values, each on a new line.
and
The array must be displayed in reverse order.
Why is this?
If it asked to first reverse the contents in the array and THEN print it. I would understand. But I'm not sure why my code is not working. Please help.
package com.codegym.task.task07.task0704;
import java.io.BufferedReader;
import java.io.InputStreamReader;
/*
Flip the array
*/
public class Solution {
public static void main(String[] args) throws Exception {
int[] array = new int[10];
BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
for (int i = 0; i < array.length; i++) {
array[i] = Integer.parseInt(reader.readLine());
}
for (int j = 9; j > 0; j--) {
System.out.println(array[j]);
}
}
}