title: charAt in method not working
body: <p>here is the method:</p>
  
  <pre><code>    public static String getEncrypted(String x){
      char y;
      String output = " ";
      int count = 0, position = 0, place= 0;
      int length = x.length();
      while(count &lt; length){
          place = length - position;
          y = x.charAt(place);
          position++;
          count++;
          output = output + y;
      }
      return output;
  }
  </code></pre>
  
  <p>I am able to compile the code which basically takes a string splits it up into the words that make it then feeds it to this method.</p>
  
  <p>When I use the program and enter something to be used by this method I get the error message </p>
  
  <pre><code>Exception in thread "main" java.lang.StringIndexOutOfBoundsException: String index out of range: 4
      at java.lang.String.charAt(Unknown Source)
      at encrypt.getEncrypted(encrypt.java:37)
      at encrypt.main(encrypt.java:23)
  </code></pre>
  
  <p>My question is what I am doing wrong and how do I fix it?</p>