public class RecursivePalin { public static void main(String[] args) { String s = "racecar"; boolean ans; ans = isPalindrome(s); } public static boolean isPalindrome(String w) { boolean helpSol; boolean mySol; if ( w.length() <= 1 ) { // base cases return true; } else { int lastPos = w.length() - 1; String h = w.substring(1, lastPos); // So I can use Step Into helpSol = isPalindrome( h ); mySol = (w.charAt(0) == w.charAt(lastPos)) && helpSol; return mySol; } } }