Iterating over the characters in a string

I was wondering what would be the fastest method to iterate over the characters in a string with Java. A small test implements the following things:

  • using an Iterable
  • toCharArray()
  • charAt()
  • calling charAt() on a CharSequence

You can download the Eclipse project as a tar or zip or browse the code online here; have a look at the StringIteratorTest class first.

Continue reading →