
public class Tools
{
   public static boolean isPalindrome(String w)
   {
       int  lastPos = w.length()-1;
       
       return isPalindrome(w, 0, lastPos);
   }

   private static boolean isPalindrome(String w, int startPos, int endPos) 
   {
      if ( startPos >= endPos )
      {  // Base case
         return true;
      }
      else 
      {
         // Solve a smaller problem that helps us solve the original problem
         boolean helpSol = isPalindrome(w, startPos+1, endPos-1);
 
         return (w.charAt(startPos) == w.charAt(endPos)) && helpSol;
      }
   }
} 

