Here’s how you use StringBuilder
Posted: February 19th, 2008 | Author: Nischal Shetty | Filed under: Java | 2 Comments »Now get out of that bad habit of using String objects to perform operations on strings. With StringBuilder(introduced in J2Se 5.0), you can perform those very append and other such operations more efficiently.
Scene 1: typical coder…. using the same old String object to perform append operations.
String s = “Hello”;
s = s + ” World”;
system.out.println(s);
I agree it’ll give you “Hello World”, but fella…. let’s be different from the rest and think about making the code more efficient.
Enter Scene 2.
StringBuilder sb = new StringBuilder(“Hello”);
sb.append(” World”);
system.out.println(sb);
well… thats it!! You’ll get your “Hello World” but in a more efficient way












Thanks,Its very much informative and easy to get.
good answer..thanks