Why does this faill on creating two small arrays?
package com.codegym.task.task07.task0705;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.Arrays;
/*
One large array and two small ones
*/
public class Solution {
public static void main(String[] args) throws Exception {
//write your code here
//This sets up a large Array and puts its length into total
BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
int[] intArrayLarge = new int[20];
int total = intArrayLarge.length;
//Now we split the large array into two smaller ones.
//Now populate our large array from the keyboard.
for (int i = 0; i < intArrayLarge.length ; i++) {
String s = reader.readLine();
intArrayLarge[i] = Integer.parseInt(s);
}
//If the large array contains an odd number the extra is to go in the first small array.
// int[] intArraySmallOne = new int[(total + 1)/2];
int[] intArraySmallOne = new int[(total)/2];
int[] intArraySmallTwo = new int[total - intArraySmallOne.length];
//This puts the first set of numbers into the firs small array then the rest into the second.
for (int i = 0; i < total; i++) {
if (i < intArraySmallOne.length) {
intArraySmallOne[i] = intArrayLarge[i];
}
else
intArraySmallTwo[i - intArraySmallOne.length] = intArrayLarge[i];
}
// System.out.println(Arrays.toString(intArraySmallOne));
for (int i = 0; i < intArraySmallTwo.length ; i++) {
System.out.println(intArraySmallTwo[i]);
}
}
}