title: StringIndexOutOfBoundsException error from stringbuilder within a while loop
body: <p>The assignment is to, for example, remove char '<code>a</code>' from the String "<code>I am Sam am I Sam</code>", this is a bit code I have so far:</p>
  
  <pre><code>public String removeLetters() {
      String cleaned=sentence;
      StringBuilder builder = new StringBuilder(cleaned);
  
      while(cleaned.indexOf(lookFor) != -1) {
          builder.deleteCharAt(cleaned.indexOf(lookFor));
      }
      return builder.toString();
  }
  </code></pre>
  
  <p>This method returns fine when there's no while loop (though it only removes one char), but when I run it with the while loop I get the <code>OutOfBounds</code> error.</p>