J
Jason Cavett
Alright, I realize that manually building strings via the String
concatenation operator (AKA: string3 = string1 + string2) is a very
expensive operation due to how Java handles it. As far as I know,
during String concatenation, Java creates a StringBuffer, appends the
two arguments together and the calls toString() on the StringBuffer to
return the String.
So, my question is - would it be better for me to use StringBuilder
most of the time? It seems like it would be in all cases where I'm
doing quite a bit of concatenation. However, for a single
concatenation, I'm not sure this is going to be any kind of
improvement.
Thanks for any insight.
concatenation operator (AKA: string3 = string1 + string2) is a very
expensive operation due to how Java handles it. As far as I know,
during String concatenation, Java creates a StringBuffer, appends the
two arguments together and the calls toString() on the StringBuffer to
return the String.
So, my question is - would it be better for me to use StringBuilder
most of the time? It seems like it would be in all cases where I'm
doing quite a bit of concatenation. However, for a single
concatenation, I'm not sure this is going to be any kind of
improvement.
Thanks for any insight.