Tag

Compile-time Constant

0 views collected around this technical thread.

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 ConstantConstant FoldingJVM
0 likes · 11 min read
Why Java Creates Only One String Object: Understanding Constant Folding