title: String to remove characters from string 1
body: <pre><code>StringBuffer a = new StringBuffer(string1);
  StringBuffer b = new StringBuffer(string2);
  String res = &quot;&quot;;
  for(int i=0; i&lt;a.length(); ){
     for(int j=0; j&lt;b.length(); j++){
        if(a.charAt(i) == b.charAt(j)){
           a.deleteCharAt(i);
           b.deleteCharAt(j);
           j=0;
           if(b.length() == 0) return a.toString();
       }else{
           i++;
     }
  }
  for(int i=0; i&lt;a.length(); i++){
    res += a.charAt(i);
   }
      return res;
  </code></pre>
  <p>I am getting Runtime ErrorException in thread &quot;main&quot; java.lang.StringIndexOutOfBoundsException: index 14,length 14<code>enter code here</code>
  at java.base/java.lang.String.checkIndex(String.java:3278)
  at java.base/java.lang.AbstractStringBuilder.charAt(AbstractStringBuilder.java:307)
  at java.base/java.lang.StringBuffer.charAt(StringBuffer.java:242)
  at Solution.removeChars(File.java:34)
  at GFG.main(File.java:16)</p>