How to print reverse string in Java recursively?

public class Reverse{

	public static void main(String[]args){
		doubleReverse("Java");
	}

	public static void doubleReverse(String s){
		int l = 0;
		if(null == s || 0 == (l = s.length()))
			return;
		char c = s.charAt(--l);
		System.out.printf("%c%c", c, c);
		s = s.substring(0,l);
		doubleReverse(s);
	}
}
Download

Comments

Popular posts from this blog