Deprecated Garbage Collections – Kenny Lee Chee Wei

Archive for the ‘Performance’ Category

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);

Written by kennii

August 9, 2007 at 5:02 pm

Posted in Performance