title: Exception in thread "main" java.lang.StringIndexOutOfBoundsException: String index out of range: 52
body: <p>I started learning Java 2 months ago and get stuck with this problem. Could anyone give me help on this one，please?</p>
  
  <p>The Questions:</p>
  
  <blockquote>
    <p>Given a string, for each digit in the original string, replaces the digit with that many occurrences of the character following.</p>
    
    <p>So the string "a3tx2z" yields "attttxzzz".</p>
  </blockquote>
  
  <p>My code:</p>
  
  <pre><code>    @param str
      @return blown up string
      public static String blowup(String str) {
      StringBuilder stri = new StringBuilder(str);
      for(int i = 0; i&lt;stri.length();i++){
          if(Character.isDigit(stri.charAt(i))){
              int a = stri.charAt(i),
                  c = a - 1;
              char b = str.charAt(a+1);           
              while (a &gt;0){
                  stri.insert(c, b);
                  a --;
              }
          }
      }
      str = stri.toString();
      return str; // TODO ADD YOUR CODE HERE
  }
  </code></pre>
  
  <p>The exception:</p>
  
  <pre><code>Exception in thread "main" java.lang.StringIndexOutOfBoundsException: String index out of range: 52
  at java.lang.String.charAt(String.java:658)
  at HelloWorld.blowup(HelloWorld.java:15)
  at HelloWorld.main(HelloWorld.java:6)
  </code></pre>