-
Enhancement
-
Resolution: Unresolved
-
P4
-
None
-
8, 11, 17, 21
-
None
JLS 15.18.1. "String Concatenation Operator +" unconditionally requires to create a new String object during concatenation with + (except for constant expressions).
This seems excessive when one or both operands are empty strings.
For example, given:
var s = "abc"
var t = ""
the expression
s + t == s
evaluates to false because s + t cannot just evaluate to s.
If nothing speaks against, concatenation with + should be allowed to return one of the operand if the other is empty.
This already happens with String.concat(String).
This seems excessive when one or both operands are empty strings.
For example, given:
var s = "abc"
var t = ""
the expression
s + t == s
evaluates to false because s + t cannot just evaluate to s.
If nothing speaks against, concatenation with + should be allowed to return one of the operand if the other is empty.
This already happens with String.concat(String).