In java how can we use the concept of stringbuilder
1
Expert's answer
2014-12-15T00:50:38-0500
If you use Stringconcatenation in a loop (something like: String s =""; for(int i = 0; i <100; i++) { s += ", " + i; } then you should usea StringBuilder (not StringBuffer)instead of a String, because it is much faster and consumes less memory. If you have a singlestatement: String s = "1," + "2, " + "3, " + "4, " ....; then you can useStrings, because the compiler will use StringBuilder automatically.
Comments