Question: Write a method called recAdd that will add the (integer) elements of an array. For example if the array were {4,8,10} the method would return
Write a method called recAdd that will add the (integer) elements of an array. For example if the array were {4,8,10} the method would return 22. Note the method will need to take as parameter the array and also the index of the last element.
public class Lab14Num2 { public static void main (String []args) { int A[] = { 3,4,16,8,-9,10}; System.out.println(recAdd(A, 5)); }
public static int recAdd(int A[], int n) //n is the index of the last element { } }
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
