What is method recursion?

A recursion is nothing but, invoking a method itself. For example, in below code snippet, the method test() calls itself.

class Abc{
public void test()
{
System.out.println("test() method");
test();
}
}

However, do not try to use above code snippet, as this will continuously gets into recursion. Programs having such endless recursion, runs until java.lang.StackOverFlowError, is being thrown. This Exception is Unchecked Exception, and is thrown when stack gets full. The reason stack gets full is, an entry is added to stack whenever a method is invoked.Continuing to add entries to stack results in overflow of stack, and java.lang.StackOverFlowError exception is thrown.

Can static method call itself recursively?

Yes, static methods can call itself recursively.

How to use method recursion, effectively?

Remember that whenever a method is called recursively, there need to be condition, which need to control it. And there need to arise a situation where this condition is satisfied.Below is program, for fibonacci, using recursion.

public class FibonacciRecursion {
	public static void main(String args[])
	{
		int i = 0, j =1;
		fib(i,j);
	}
	
	private static void fib(int x, int y)
	{
		if(x>=30)
		{
			return;
		}
		
		System.out.print(y+"  ");
		
		fib(y, x+y);
	}
}

Also note that, above recursive version is more compact compared to non recursive version of fibonacci program.

What is indirect recursion?

A method test1(), invoking test2(), test2() further invokes test1(). This is termed as indirect recursion. In the example taken there are only two methods involved, also remember that there can be more methods involved, in indirect recursion. Indirect recursion may also end up with java.lang.StackOverFlowError exception, if not used cautiously.

Below code snippet shows non recursive method, as display() invokes super.display(), and not itself.

class Abc{
public void display()
{
System.out.println("Abc.display()");
}
}

class Xyz extends Abc{
public void display()
{
super.display(); //invokes display() method of Base class
System.out.println("Xyz.display()");
}
}

You may also like to read:
When OutOfMemoryException is thrown?
Difference between checked and unchecked Exception?
Purpose of static keyword?
How to invoke Base class constructor?