Hi,
The program works but for some reason the 3rd requirement is not met. I created two int arrays of 10 in size. What's the issue?
package com.codegym.task.task07.task0705;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
/*
One large array and two small ones
*/
public class Solution {
public static void main(String[] args) throws Exception {
int[] largeArray = new int[20];
largeArray = initializeArray();
int[] firstArray = new int[10];
int[] secondArray = new int[10];
//firstArray = firstArrayCopier(largeArray);
secondArray = secondArrayCopier(largeArray);
displayArray(secondArray);
}
public static void displayArray(int[] array){
for(int i = 0; i < array.length; i++) {
System.out.println(array[i]);
}
}
public static int[] firstArrayCopier(int[] lArray) {
int[] firstArray = new int[10];
for(int i = 0; i < 10; i++){
firstArray[i] = lArray[i];
}
return firstArray;
}
public static int[] secondArrayCopier(int[] lArray){
int[] secondArray = new int[10];
int y = 0;
for(int i = 10; i < 20; i++){
secondArray[y] = lArray[i];
y++;
}
return secondArray;
}
public static int[] initializeArray() throws IOException {
int[] iArray = new int[20];
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
for(int i = 0; i < iArray.length; i++){
iArray[i] = Integer.parseInt(br.readLine());
}
return iArray;
}
}