Tuesday, February 26, 2013

StringBuilder with modern compilers

Modern Java compiler convert your + operations by StrinBuilder's append. I mean to say if you do str = str1+sr2+str3 then compiler will generate following code
StringBuilder sb = new StringBuilder();
str = sb.append(str1).append(str2).append(str3).toString();
So now its more of matter of choice than performance benefit to use + or StringBuilder :)

No comments:

Post a Comment