Java Recursion
In Java language, Recursion is a programming technique that the method calls itself is called Recursion, which means that if a program allows the programmer to call a method within in the same function, it’s called Recursion call of the method.

Syntax:-
returntype recursion() { recursion(); /* method calls itself */ }
Example:-
public class Recursion
{
static int Factorial(int n){
if (n == 1)
return 1;
else
return(n * Factorial(n-1));
}
public static void main(String[] args)
{
System.out.println("Factorial of 6 is: "+Factorial(6));
}
}

The programmer has to define exit condition from the Method, if not it will go into an infinite loop.
Quickly Find What You Are Looking For
OnlineTpoint is a website that is meant to offer basic knowledge, practice and learning materials. Though all the examples have been tested and verified, we cannot ensure the correctness or completeness of all the information on our website. All contents published on this website are subject to copyright and are owned by OnlineTpoint. By using this website, you agree that you have read and understood our Terms of Use, Cookie Policy and Privacy Policy.
point.com