title: Checking, if String is Palindrome using substring() and charAt()
body: <p>My code is supposed to ask a user to input a String and then check to see, if it is Palindrome using <code>charAt()</code> and <code>substring()</code> methods. I believe, I have done everything correctly but NetBeans is compiling it incorrectly. </p>
  
  <p>When I run my code, NetBeans tells me:</p>
  
  <pre><code>Exception in thread "main" java.lang.RuntimeException: Uncompilable source code - missing return statement
      at palindrome.Palindrome.methodA(Palindrome.java:31)
      at palindrome.Palindrome.main(Palindrome.java:27)
  Java Result: 1
  </code></pre>
  
  <p>So, basically it says I'm missing a return statement? I do not see how that is possible.</p>
  
  <p>Any help would be greatly appreciated guys. Thanks.</p>
  
  <pre><code>package palindrome;
  
  import java.util.Scanner;
  
  public class Palindrome {
  
      /**
       * Program asks user to enter a string.
       */
      public static void main(String[] args) {
          String userInput; //user-inputted String
          String result;
  
          //set up instance of Scanner for user input
          Scanner scan = new Scanner(System.in);
  
          //ask user for input
          System.out.print("Please enter a String: ");
          userInput = scan.nextLine();
  
          //run methodA
          result = methodA(userInput);
  
      }
  
      public static String methodA(String inString) {
          /*
           * This method checks the user-inputted String against a backward copy
           * of itself using only String and Character methods.
           */
  
          //next two int variables used as int pointers for first letter of String
          //and last letter of user-inputted String
          int begPoint = 0;
          int endPoint = inString.length() - 1;
  
          //define Strings to return to main method
          String isPal = (inString + " is a palindrome!");
          String notPal = (inString + " is not a palindrome.");
  
          while (begPoint &lt; endPoint) {
              //two substrings defined to test String character for character
              String firstChar = inString.substring(begPoint, begPoint + 1);
              String lastChar = inString.substring(endPoint, endPoint + 1);
  
              //algorithm continues step by step with begPoint going up one and 
              //endPoint decreasing by one
              begPoint++;
              endPoint--;
  
              //basically here I am trying to check the characters of the user-
              //inputted Strings using the charAt methods but I'm lost when I
              //get to this point
              if (inString.charAt(begPoint) == inString.charAt(endPoint)) {
                  return isPal;
              } else {
                  return notPal;
              }
          }
      }
  }
  </code></pre>
  
  <p>After some answers -- I have now changed my while statement to this: </p>
  
  <pre><code>while(begPoint&lt;endPoint) {
      //two substrings defined to test String character for character
      String firstChar = inString.substring(begPoint, begPoint + 1);
      String lastChar = inString.substring(endPoint, endPoint + 1);
  
      //basically here I am trying to check the characters of the user-
      //inputted Strings using the charAt methods 
      if (inString.charAt(begPoint) == inString.charAt(endPoint)) {
          return isPal;
      } else {
          return notPal;
      }
  
      //algorithm continues step by step with begPoint going up one and 
      //endPoint decreasing by one
      begPoint++;
      endPoint--;
  }
  </code></pre>
  
  <p>However, now it is telling me that (begPoint++) is an unreachable statement.</p>