Hi guys,
I thought I understood the conditions, but definitely, I don't or the author made it unclear on purpose.
My code is assigning values of firstArray to the resultArray, then it's assigning values of the second one, precisely in accordance with the task conditions.
Please, help!
package en.codegym.task.pro.task05.task0504;
/*
Combining arrays
*/
public class Solution {
public static int[] firstArray = new int[]{0, 1, 2, 3, 4, 5, 6, 7, 8, 9};
public static int[] secondArray = new int[]{10, 11, 12, 13, 14, 15, 16, 17, 18, 19};
public static int[] resultArray;
public static void main(String[] args) {
int[] resultArray = new int[firstArray.length + secondArray.length];
int index = firstArray.length;
for (int i = 0; i < firstArray.length; i++) {
resultArray[i] = firstArray[i];
}
for (int i = 0; i < secondArray.length; i++) {
resultArray[index] = secondArray[i];
index++;
}
for (int j = 0; j < resultArray.length; j++) {
System.out.print(resultArray[j] + ", ");
}
}
}
// public static int[] result(int[] a, int[] b) {
//
// int[] result = new int[a.length + b.length];
// int index = a.length;
// for (int i = 0; i < a.length; i++) {
// result[i] = a[i];
// }
// for (int i = 0; i < b.length; i++) {
// result[index] = b[i];
// index++;
// }
// return result;
// }