int[] newArr = new int[arr1.length]; //New List
for(int i = 0; i < newArr.length; i++) { //Go Through entire list
newArr[i] = arr1[i] + arr2[i]; //Add elements together
}
return newArr; //Return new list
}
Create a static method called sumArrays, which takes two integer arrays as input parameters. Assume these arrays have the same length. Your method should add up corresponding elements of the two arrays and put the sums into a new array which is returned as a value.
Example:
data1:{5, 6, 7, 8}
data2:{4, 5, 6, 7}
==> {9, 11, 13, 15}
I keep trying different things but am getting the same error message. Help is much appreciated! Thanks!