Click to See Complete Forum and Search --> : String and StringBuffer
debbie_82
Apr 21st, 2004, 09:22 PM
Between String and StringBuffer Classes which class executes faster?
crptcblade
Apr 21st, 2004, 09:48 PM
Executes what? If you are doing a lot of concatenation, go with a stringbuffer. It doesn't reference new memory every time you reassign it like a string does.
Dillinger4
Apr 22nd, 2004, 12:35 AM
For concatenation i would think that using a StringBuffer right from the start would allow your code to execute faster since the compiler uses StringBuffers to implement the string concatenation operator.
String s = "Hello." + "What" + "time" + "is" + "it?";
// is equivalent to......
String s2 = new StringBuffer().append("Hello").append("What").append("time").append("is").append("it?").toString();
CornedBee
Apr 22nd, 2004, 03:14 AM
Java 1.5 has a new class, StringBuilder, which works exactly like StringBuffer but is not thread-safe and thus faster.
vbforums.com
Copyright Internet.com Inc., All Rights Reserved.