Created
October 14, 2017 08:31
-
-
Save jsbonso/7e1dc479a8ace33201c2603c9c4fb21b to your computer and use it in GitHub Desktop.
Simple Recursive Method
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* A simple recursive method that outputs numbers from 1 - 10 | |
* @param number of times the method will recurse / repeat | |
* @return | |
*/ | |
static int recursiveMethod(int num) { | |
// An important line, which defines the case when will the recursion ends | |
if (num == 0) | |
return num; | |
System.out.println(num); | |
// Call itself | |
return recursiveMethod(num-1); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment