Explanation :
Recursion means calling a method within itself until it returns a value.
Code:
public class Print{
public static void recursive(int n)
{
if(n <= 10)
{
System.out.println(n);
recursive(n+1);
}
}
public static void main(String args[])
{
recursive(1);
}
}
No comments:
Post a Comment