I have quickly read over the Java8 String api documentation.
Now I am little curious about String.join() method to concat/join strings.
This kind of example
str1 + " " + str2 is internally converted into:
StringBuffer tmp1 = new StringBuffer();
tmp1.append(str1);
tmp1.append(" ");
String tmp2 = tmp1.toString();
StringBuffer tmp3 = new StringBuffer();
tmp3.append(tmp2);
tmp3.append(str2);
String result = tmp3.toString();
str1.concat(str2) will not produce the same result, as the space wont be present between the two strings.
join should be equivalent to
StringBuffer tmp1 = new StringBuffer();
tmp1.append(str1);
tmp1.append(" ");
tmp1.append(str2);
String result = tmp.toString();
and hence be faster.