Hi Guys,
Can you please help me? I am missing the last condition and don't know how to go further.
This is what I get as output when entering numbers from 1 to 8 as input:
1
2
3
4
5
6
7
8
null
null
8
7
6
5
4
3
2
1
Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException: -1
at com.codegym.task.task07.task0702.Solution.main(Solution.java:17)
Process finished with exit code 1
Thanks!
package com.codegym.task.task07.task0702;
import java.io.BufferedReader;
import java.io.InputStreamReader;
public class Solution {
public static void main(String[] args) throws Exception {
BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
String[] myArray = new String[10];
for (int i = 0; i < myArray.length-2 ; i++) {
myArray[i] = reader.readLine();
}
for (int i = 9; i < myArray.length; i--) {
System.out.println(myArray[i]);
}
}
}