5 replies
Could you please pass on the string values and their declarations?
Try using StringBuffer instead of String and use the StringBuffer.append() to concatenate strings.
by superdoum
by michael
Yes, as noted above, you should use a StringBuffer for any "stringy" object whose value can change.
The Java language doesn't create string "variable" as such - it creates individual String objects as needed to hold literal values and returns handle references to them.
Pointers to existing strings with the desired values are assigned if possible at compile time.
But if you assign a series of values to a String object at run time, you're actually generating a potentially great number of separate objects.
So, use StringBuffer! See the following URL in the Java Language Specification on Sun's Web site:
http://java.sun.com/docs/books/jls/first_edition/html/javalang.doc12.html#14461
by superdoum
by superdoum
This discussion is closed to new replies.
Trending Web Development posts
Sort by Trending