StringBuffer vs. StringBuilder

Here’s a nice blog entry by Daniel Pietraru showing how StringBuilder is around 34% faster than StringBuffer for single threaded applications. Even includes bytecode analysis for plain String concatenation, something I’ve always been curious about.

  1.         StringBuilder concat = new StringBuilder(BUFFSIZE);  
  2.         for (int i = 0; i < ITERATIONS; i++) {  
  3.             concat.append(i % 10);  
  4.         }
This entry was posted on Tuesday, July 29th, 2008 at 3:58 am and is filed under Java. You can follow any responses to this entry through the RSS 2.0 feed. You can leave a response, or trackback from your own site.

Leave a reply

Name (*)
Mail (will not be published) (*)
URI
Comment