Write a static recursive method that returns the sum of the integers in the array of int values passed to it as a single argument. You can assume that every indexed variable of the array has a value. Embed the method in a test program.
The insight for this problem is to realize that the array passed each iteration must be diminished by one element and the base case is when the passed array has just one element. In order to pass a diminished array, another, temporary, array must be created that is a copy of all but the highest-index value of the passed array. The return value should be the sum of the value at the highest-index of the passed array plus the return value from the call to sumOfInts.
See the code in SumOfIntsDemo.java.
You might also like to view...
A chart can be used to create a visual depiction of text and graphical data
Indicate whether the statement is true or false
Routers use logical addresses as their unique identifiers.
Answer the following statement true (T) or false (F)
A(n) ___________ is the interface pipeline that connects two information systems
a. HL7 message b. Continuity of care document c. Thread d. None of the above
Pressing the ____ key on the keyboard will activate the brush to paint in a layer mask.
A. F B. right bracket ( ] ) C. B D. E