Tagged articles
1 articles
Page 1 of 1
macrozheng
macrozheng
Jul 3, 2023 · Fundamentals

Why Java Creates Only One String Object: Understanding Constant Folding

This article explains how Java's compiler optimizes string concatenation through constant folding, the rules that define compile‑time constants, and why only a single String object is created in many seemingly multiple‑object scenarios.

Compile-time ConstantJVMString pool
0 likes · 11 min read
Why Java Creates Only One String Object: Understanding Constant Folding