According to this link, in Java versions 1.5 String s="abc"+"xyz";only one object is created in the code due to compiler optimization using the StringBuilder class.
new StringBuilder().append(abc).append(xyz).toString()
Does this mean that before java 1.5 String is used to create three objects: one "abc", another "xyz" and the third "abcxyz" OR then it uses some other class, for example StringBuffer, for similar optimization of the compiler?
source
share