I'm sorry to disappoint you, but Java String-Pool is not a real Java class, but somewhere implemented in the JVM, that is, it is written as C ++ code. If you look at the source code of the String class (almost completely down), you will see that the intern() method is native. For more information you will have to go through the JVM code.
Edit: Some implementation can be found here ( C ++ header, C ++ implementation ). Find StringTable .
Edit2: As Holger pointed out in the comments, this is not a strict requirement for a JVM implementation. Thus, it is possible to have a JVM that implements a string pool in different ways, for example. using the actual Java class. Although all the widely used JVMs I know that I implement it in C ++ JVMs code.
Martins
source share