Question: I need help with an assignment, I have to change a given method to a generic method that is supposed to be a recursive as
I need help with an assignment, I have to change a given method to a generic method that is supposed to be a recursive as well. The method is supposed to return a sum from the given parameters.
- Write a recursive method to sum the values in an integer array (the sumOfArray() )
- In addition, make it to be a generic method
The given code is this: /** * Recursive method for generating sum of values in array * @param arr array of Integers * @param num index of array to sum all previous index values (including num) * @return sum of array values */ public static int sumOfArray(Integer[] arr, int num) { // Implement your code here return 0; } ---------------- I've tried doing this: public static
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
