Singh M.
Posts: 154
Nickname: ms
Registered: Mar, 2002
|
|
Re: string and string buffer??
|
Posted: Aug 26, 2002 4:23 PM
|
|
Senthil, please read the java documentation of String and StringBuffer. That will help clarify these small things.
Anyway, from the javadoc of StringBuffer...
String buffers are used by the compiler to implement the binary string concatenation operator +. For example, the code:
x = "a" + 4 + "c" is compiled to the equivalent of:
x = new StringBuffer().append("a").append(4).append("c") .toString() which creates a new string buffer (initially empty), appends the string representation of each operand to the string buffer in turn, and then converts the contents of the string buffer to a string. Overall, this avoids creating many temporary strings.
|
|