I am aware of String concatenation: concat() vs "+" operator
But i have question on usage of both concat() and + operator effectively
concat() is more efficient than + operator but still we are using + operator in few cases below
Case 1
System.out.println("Hi! Welcome: "+nameString);
Case 2:
splitting huge length line in to multiple lines(eclipse formatting)
System.out.println("Hi! Welcome: "+nameString1
+nameString2
+nameString3);
why still we are using + operator instead of concat()?
"Hello".concat("World").concat("!")instead of"Hello" + "World" + "!"? A: There's no reason to do so, because it's much more concise and readable using+, and the possible performance penalty is absolutely no issue 99.99999% of the time.+operation is applied in compile-time if possible.