Which one will be better use for Concatenation of String
If i want to build a string from bunch of string variables such as str1 and str2, which one will be better one ???
- String Concat operator
String str="This the String1 " + str1 + " merged with Sting2 " + str2;
- String format method
String str=String.format("This the String1 %s merged with Sting2 %s", str1 , str2);
What i think is second one will be better , because first one will suffer from creation of lot of string.
correct me if i am wrong ? and provide feedback on same