Recursion with Java: More LINK:
A recursive function is a function that calls itself. As if you are ordering yourself to something for you; it is good sometime, you earn go to ban put money for college fund, if you forget you ask your self to do it. It is not humanly possible, but possible with computer languages, as you introduce every object and store before you use it, so a mechanical work can be ordered by the same machine.

Example 1:

import java.io.*;
public class test {
public static void main(String args[])throws IOException //this is an entry function must have
{
test t = new test();
t.method1();
System.out.print("\tleft method1 : ");
}
public void method1()throws IOException
{
String str="";
InputStreamReader isr = new InputStreamReader(System.in);
BufferedReader br = new BufferedReader(isr);
System.out.print("Type some thing : ");
str =br.readLine();
if(str.equals("exit"))
{
str= "good day";
System.out.println(str);
}
else
{
method1();
}
}
}

 

In the example below we wrote a routine that will do some calculation

 

//import java.io.*;
public class test {
public static void main(String args[])//this is an entry function must have
{
System.out.println("baba loves java! and soccer");
int theAnswer = cal_recursive(6);
System.out.println("cal_recursive=" + theAnswer);
}
public static int cal_recursive(int n) {
int result;
if (n == 1 || n==2)
result= 1;
else
result= (n + cal_recursive(n - 1))+ (n + cal_recursive(n - 2));
return result;
}
}