recursively sum the integers in an array

前端 未结 9 1002
不思量自难忘°
不思量自难忘° 2020-12-06 03:01

I have a program that I\'m trying to make for class that returns the sum of all the integers in an array using recursion. Here is my program thus far:

public         


        
9条回答
  •  失恋的感觉
    2020-12-06 03:46

    a[n-1] 
    

    is getting the int at n-1, not the array from 0 to n-1.

    try using

    Arrays.copyOf(a, a.length-1);
    

    instead

提交回复
热议问题