Best practices/performance: mixing StringBuilder.append with String.concat

前端 未结 9 552
孤独总比滥情好
孤独总比滥情好 2020-12-07 08:23

I\'m trying to understand what the best practice is and why for concatenating string literals and variables for different cases. For instance, if I have code like this

9条回答
  •  情话喂你
    2020-12-07 09:06

    I personally prefer the Strings.format(), simple easy to read one-line string formatter.

    String b = "B value";
    String d = "D value";
    String fullString = String.format("A %s C %s E F", b, d);
    // Output: A B value C D value E F
    

提交回复
热议问题