Is chain of StringBuilder.append more efficient than string concatenation?

2011-09-29T00:14:18

According to Netbeans hint named Use chain of .append methods instead of string concatenation

Looks for string concatenation in the parameter of an invocation of the append method of StringBuilder or StringBuffer.

Is StringBuilder.append() really more efficient than strings concatenation?

Code sample

StringBuilder sb = new StringBuilder();
sb.append(filename + "/");

vs.

StringBuilder sb = new StringBuilder();
sb.append(filename).append("/");

Copyright License:
Author:「Marek Sebera」,Reproduced under the CC 4.0 BY-SA copyright license with link to original source & disclaimer.
Link to:https://stackoverflow.com/questions/7586266/is-chain-of-stringbuilder-append-more-efficient-than-string-concatenation

About “Is chain of StringBuilder.append more efficient than string concatenation?” questions

According to Netbeans hint named Use chain of .append methods instead of string concatenation Looks for string concatenation in the parameter of an invocation of the append method of StringBuild...
I found concatenations of constant string expressions are optimized by the compiler into one string. Now with string concatenation of strings only known at run-time, why does the compiler not opti...
I have some code like this: StringBuilder rgba = new StringBuilder(); for (...){ .... rgba.append(value + ", "); } IntelliJ shows me the following warning: string concatenation as argu...
I am currently working my way through the Learn you a Haskell book online, and have come to a chapter where the author is explaining that some list concatenations can be inefficient: For example (...
Is there an efficient mass string concatenation method in Python (like StringBuilder in C# or StringBuffer in Java)? I found following methods here: Simple concatenation using + Using a string lis...
I'm running a process that creates a very large number of feature vectors (as numpy arrays) and stacks them into a single array. This process is currently very memory intensive and I'm looking for ...
This is a follow up question to : Concatenation by += slower than that by using StringBuilder() where I found out that string1+=string2 is much slower than string1.append(string2) where string1 is ...
I have an RDD[(String, (String, Double))]. Currently the RDD contains duplicates in the key field. I want to get an RDD[(String, Map[String, Double])] (does not need to be a vanilla map, just some ...
It's recommended (PMD rule AppendCharacterWithChar) to use StringBuilder.append(char) instead of StringBuilder.append(String). I agree with that. But if I want to append a (short) string like "='"...
This question is relevant to MySQL databases or tables that exceed 1 million rows. As each row shall have a unique ID (or code) which is later used to create relationships between several tables,...

Copyright License:Reproduced under the CC 4.0 BY-SA copyright license with link to original source & disclaimer.