I'm doing a short lab for school where it takes 10 integers from scanner input and stores them in an array, then copies the data to a second array, then prints the first array forwards, and the second array backwards.
code:
import java.util.Arrays;
import java.util.Scanner;
public class APSummerLab00
{  
   public static void main(String args[])
   {
       int[] array = new int[10]; 
       int[] array2 = new int[10];
       int one, two, three, four, five, six, seven, eight, nine, ten;
       Scanner input = new Scanner(System.in);
       array[1] = input.nextInt();
       array[2] = input.nextInt();
       array[3] = input.nextInt();
       array[4] = input.nextInt();
       array[5] = input.nextInt();
       array[6] = input.nextInt();
       array[7] = input.nextInt();
       array[8] = input.nextInt();
       array[9] = input.nextInt();
       int x = 10;
       for(int i = 0; i<= array.length; i++)
       {
         array2[x] = array[i];
         x--;
       }
   System.out.println(Arrays.toString(array));
   System.out.println(Arrays.toString(array2));
   }
}
On the line in the for loop array2[x] = array[i]; I get the error
"Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException: 10"
basically with that line I used a for loop that increments by 1 from 0, and I want to say array2 is going to increment by -1 and make the array2 the backwards version of array.