There will be one string object in the string pool. "a" + "b" + "c"
is resolved to "abc"
at compile time (see JLS §15.28), so what you have is equivalent to
String s = "abc";
There are no StringBuilder
s involved here, contrary to what the accepted answer of the duplicate question asserts. You can even see this in the bytecode:
LDC "abc"
ASTORE 1
From the JLS link above:
Compile-time constant expressions of type String
are always "interned" so as to share unique instances, using the method String.intern
.