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
{
}
}

Write a method called recAdd that will add the integer ele.pdf

  • 1.
    Write a methodcalled 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 { } }