intern
Java String.intern()
The method intern() creates an exact copy of a String object in the heap memory and stores it in the String constant pool.
Note that, if another String with the same contents exists in the String constant pool, then a new object won’t be created and the new reference will point to the other String.