String demo="a" + "b";
The default JDK generate three objects, this is well understood, but that some optimization JDK yield two objects, to create the two objects? In the memory area
CodePudding user response:
Have three objects, are in constant area,A="a".
A + b="b" this is not the same again
CodePudding user response:
You through the ide, decompiled look at will know that optimized String demo="ab"; A "ab" a demoCodePudding user response:
Three objects: "a", "b", "demo" - & gt; Pointing to the "ab"