jmeter-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From chaitanya bhatt <>
Subject Re: StringBuilder against compile time String concatenation
Date Wed, 31 Dec 2014 18:15:03 GMT
Concatenation with + operator will be internally converted to a
StringBuffer( as synchronized version of StringBuilder class). IMO there
isn't much performance difference unless you are trying to concatenate in a
loop, in such cases StringBuilder would be a better option.

Also, since StringBuffer is synchronized, depending on how you are using
the String object in the VM StringBuilder may outperform "+" approach.
(Take a look a the StackOverflow discussion)

Also, I feel StringBuilder improves readability of a code.


Chaitanya M Bhatt

On Sun, Dec 28, 2014 at 4:34 AM, Felix Schumacher <> wrote:

> Hi all,
> in XPathUtil I have found the following code fragment:
>   log.debug(new StringBuilder("bla").append(blub).append("whatever").
> toString())
> which seems to me t be equivallent to
>   log.debug("bla"+blubb+"whatever")
> any reason to use the former?
> Regards
>  Felix

  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message