title: Standard way to iterate over a StringBuilder in Java?
body: <p>I was quite surprised that I couldn't find an existing questions answering this.</p>
  
  <p>What is the standard way to iterate over all characters in a StringBuilder in Java?</p>
  
  <p>The obvious route is to just convert it to a String then use toCharArray(). The problem is, I'm dealing with thousands of unique strings, with which I do a lot of appending, and I think I'm getting memory and performance issues from having to intern them all.</p>
  
  <p>EDIT: to clarify, I'm not manually interning Strings, but my understanding was that they were automatically interned, and that if I called <code>toString</code> for a StringBuilder that they would be interned. Perhaps I have misunderstood.</p>