public static int runProcess(int[] arr)
{
//Call our recursive method and send it the array and our starting case, 0
return addElements(arr,0);
}
public static int addElements(int[] arr, int count)
{
//Get the number in the position in our array
int tempNum = arr[count];
//Check to see if the current number is the last number in the array. arr.length-1 is used
//because the array starts at 0
if(count==arr.length-1)
{
//This is the last element, return it the previous addElements call
return tempNum;
}
//Add our number and call the next addElements method. Remember to increase count by 1
//so we progress through the array.
return tempNum + addElements(arr,count++);
}