Deprecated Garbage Collections – Kenny Lee Chee Wei

A truckload of garbage by Kenny Lee Chee Wei

Strings

leave a comment »

  1. String s = "f" + "o" + "o"
  2. is faster than

    String s = "f";
    s+="o";
    s+="o";

  3. The comparison
    ('a' == s.charAt(0))
  4. is faster than

    s.startsWith("a");

  5. The StringBuffer default capacity is 16. If your string is going to be larger than that, you might as well reserve a larger capacity by passing a realistic length such asStringBuffer sb = new StringBuffer(1024);
Advertisements

Written by kennii

August 9, 2007 at 5:02 pm

Posted in Performance

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: