Archive for the ‘Performance’ Category
Strings
String s = "f" + "o" + "o"
- The comparison
('a' == s.charAt(0))
- 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 as
StringBuffer sb = new StringBuffer(1024);
is faster than
String s = "f";
s+="o";
s+="o";
is faster than
s.startsWith("a");