Su San Talks Tech
Jun 24, 2023 · Fundamentals
Why Java Creates a Single String Object on Concatenation – Exploring Constant Folding
This article explains how Java’s compiler applies constant folding to compile‑time constants, turning string concatenations like "a"+"b"+"c" into a single String object, distinguishes compile‑time versus runtime constants, and demonstrates the impact on the constant pool and equality comparisons.
Compile-time ConstantsJVMJava
0 likes · 9 min read
