java, jvm

Before JDK6, constant pools were part of the permanent zone, but after JDK7, they were moved to the heap for management.

The string. int () method obtains a symbol reference in the constant pool, and if the constant string does not exist in the constant pool, the method adds the string to the constant pool.

Although the return value of the String.intern method is always equal to the string constant, it does not mean that the inter return of the same string is the same at all times of the system. (Although it is the same in more than 95% of cases). Because there is a possibility that after an intern, the string is recycled at a certain time and then an intern call is made, then strings with the same literal amount are added to the constant pool again, but the reference positions are different.