Java recursive functions explained // Using recursion to sum an array of numbers 4


Java is a very powerful object oriented language. If you search for recursion in wikipedia you will find this definition Recursion, in mathematics and computer science, is a method of defining functions in which the function being defined is applied within its own definition.” This means, that the function will call itself again and again until it gets the correct answer.

There are many pages where you can find great explanations to recursion theory. Most of them use the example of the Towers of Hanoi:

What I’m going to show you is an easy way to sum arrays of numbers. This example lets you see how easy can recursion be and how useful it is.


Leave a comment

Your email address will not be published. Required fields are marked *

4 thoughts on “Java recursive functions explained // Using recursion to sum an array of numbers