Memory model

Understanding the Java String.intern() Memory Model

Understanding the Java String.intern() Memory Model

Calling string.intern() in Java first looks up the corresponding string in the string constant pool; if it doesn't exist, the string is created in the pool and then returned.