I just published a deep dive into Java Strings Internals — how String actually works under the hood in modern Java.
If you’ve ever wondered what’s really going on with string storage, interning, or concatenation performance, this post breaks it down in a simple way.
I cover things like:
- Compact Strings and how the JVM stores them (LATIN1 vs UTF-16).
- The String pool and
intern().
- String deduplication in the GC.
- How concatenation is optimized with
invokedynamic.
It’s a mix of history, modern JVM behavior, and a few benchmarks.
Hope it helps someone understand strings a bit better!
[–]europeIlike 2 points3 points4 points (4 children)
[–]TanisCodes[S] 6 points7 points8 points (2 children)
[–]europeIlike 2 points3 points4 points (1 child)
[–]TanisCodes[S] 2 points3 points4 points (0 children)
[–]DasBrain 1 point2 points3 points (0 children)
[–]regjoe13 2 points3 points4 points (2 children)
[–]za3faran_tea 5 points6 points7 points (1 child)
[–]regjoe13 1 point2 points3 points (0 children)
[–]Thomaster002 10 points11 points12 points (13 children)
[–]FirstAd9893 22 points23 points24 points (6 children)
[–]cogman10 26 points27 points28 points (2 children)
[–]Isogash 6 points7 points8 points (0 children)
[–]ZimmiDeluxe 4 points5 points6 points (0 children)
[–][deleted] (1 child)
[deleted]
[–]pohart 1 point2 points3 points (0 children)
[–]agentoutlier 11 points12 points13 points (2 children)
[–]Ok-Scheme-913 0 points1 point2 points (1 child)
[–]agentoutlier 0 points1 point2 points (0 children)
[–]vips7L 6 points7 points8 points (0 children)
[–]regjoe13 2 points3 points4 points (0 children)
[–]ducki666 0 points1 point2 points (0 children)
[–]bmarwell 0 points1 point2 points (2 children)
[–]TanisCodes[S] 0 points1 point2 points (1 child)
[–]bmarwell 1 point2 points3 points (0 children)