title: Palindrome Program using Recursion
body: <p>This is currently what I have for my Palindrome program for my computer science class. I have it pretty much working, except whenever a word is a palindrome, it is an infinite loop. I know I have to insert a number base case, but I do not how to do that...I'm really having trouble understanding recursion. Help is appreciated.</p>
  
  <pre><code>public class PalindromeTester
  {
      public static void main(String[] args)
      {
          Scanner scan = new Scanner (System.in);
  
          String str, another = "y";
          int left, right;
  
          while (another.equalsIgnoreCase("y"))
          {
  
              System.out.println("Enter a potential palindrome:");
              str = scan.next();
  
              left = 0;
              right = str.length() - 1;
  
              tester(str, left, right);
  
              System.out.println();
              System.out.println("Test another palindrome (y/n)?");
              another = scan.next();
  
          }
      }
  
      public static void tester (String str, int left, int right)
      {
          Scanner scan = new Scanner (System.in);
  
  
          while (str.charAt(left) == str.charAt(right) &amp;&amp; left &lt; right)
          {
              System.out.println(str);
  
              tester( str, left + 1, right -1);
  
          }
          if (left &lt; right)
          {
              System.out.println("That string is NOT a palindrome.");
          }
  
          else 
          {
  
              System.out.println("That string IS a palindrome.");
          }
  
      }
  }
  </code></pre>