public String intern() returns the normalized representation of the string object. An initially empty string pool maintained privately by class String. When the intern method is called, if the pool already contains a string equal to this String object (determined using the equals(Object) method), the string in the pool is returned. Otherwise, adds this String object to the pool and returns a reference to this String object. It follows the following rule: for any two strings s and t, s.intern() == t.intern() is true if and only if s.equals(t) is true. All literal strings and string assignments constantsexpressions operate using the intern method. String literals are defined in §3.10.5 of the Java Language Specification. Returns: a string with the same contents as this string, but must be taken from a pool with unique strings.
[Related recommendations]
2.Analysis of intern() in Java Function
3. Detailed explanation of intern() in String object
4. In-depth analysis of intern() method in Java
5. Summary of experience in using intern() method in JAVA
The above is the detailed content of What is the concept of intern method in java. For more information, please follow other related articles on the PHP Chinese website!