0

From my knowledge, I know I can use concat() in such manner:

String str = "to";
System.out.println(str.concat("gether")

Which returns together. But isn't that just like saying str + "gether"?

Why make a method for it when you can just use + to join Strings together?

Does it serve any other purpose?

Max Echendu
  • 203
  • 1
  • 3
  • 8
  • 1
    Have you tried decompiling the result of `System.out.println(str + "gether")`? Without a suitable method, what would you expect the bytecode to look like? (It could use `StringBuilder`, but that would be a bit of a waste...) – Jon Skeet Aug 25 '15 at 15:12
  • 5
    Someone posted a good explanation already: http://stackoverflow.com/questions/47605/string-concatenation-concat-vs-operator – Lucas McGregor Aug 25 '15 at 15:14

0 Answers0