Thursday, February 23, 2012

Recursive string reversal- reverse string



public class MyClass {
       public String reverse(String newstring) {
            if ((null == newstring) || (newstring.length() <= 1)) {
                return newstring;
            }
            return new StringBuffer(newstring).reverse().toString();
        }
}


No comments:

Post a Comment