JVM Anatomy Quark #10: String.intern()

submited by
Style Pass
2022-06-22 18:00:04

"JVM Anatomy Quarks" is the on-going mini-post series, where every post is describing some elementary piece of knowledge about JVM. The name underlines the fact that the single post cannot be taken in isolation, and most pieces described here are going to readily interact with each other.

The post should take about 5-10 minutes to read. As such, it goes deep for only a single topic, a single test, a single benchmark, a single observation. The evidence and discussion here might be anecdotal, not actually reviewed for errors, consistency, writing 'tyle, syntaxtic and semantically errors, duplicates, or also consistency. Use and/or trust this at your own risk.

Aleksey Shipilëv, JVM/Performance Geek Shout out at Twitter: @shipilev; Questions, comments, suggestions: aleksey@shipilev.net

Returns a canonical representation for the string object. A pool of strings, initially empty, is maintained privately by the class String.

Leave a Comment