I am working on a program in eclipse to split an array into two arrays of equal size. My program compiles, but when I run it I get the following error message:

> 
> Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException:
>  10000 at mergeArrays.main(mergeArrays.java:28)
> 
> 
> 

If you have any suggestions as to why I am getting this error it would be greatly appreciated. Thanks in advance!

Here is my code:

```
import java.util.Scanner;
import java.util.Random;

public class mergeArrays {

    public static void main(String[] args) {
        Scanner input = new Scanner(System.in);
        //System.out.print("Enter an upper limit: ");
        //int lim = input.nextInt();
        int lim = 10000;
        int halfLim;
        halfLim = lim / 2;
        //int data[];
        //data = new int[lim];

        double[] data = new double[lim];
        for (int i = 0; i < lim; i++) {
            data[i] = Math.random();
        }

        double[] a = new double[halfLim];

        for (int i = 0; i < halfLim; i++) {
            a[i] = data[i];
        }

        double[] b = new double[halfLim];
        for (int i = halfLim; i < lim; i++) {
            b[i] = data[i];
        }

        System.out.print(a);
    }
}

```