String.Intern Method Reference Feedback Definition Namespace: Java.Lang Assembly: Mono.Android.dll Returns a canonical representation for the string object. C# Copiar [Android.Runtime.Register("intern", "()
initially empty, is maintained privately by the * class {@code String}. * * When the intern method is invoked, if the pool already contains a * string equal to this {@code String} object as determined by * the {@link #equals(Object)} method...
* When the intern method is invoked, if the pool already contains a * string equal to this {@codeString} object as determined by * the {@link#equals(Object)} method, then the string from the pool is * returned. Otherwise, this {@codeString} object is added to the * pool and a re...
initially empty, is maintained privately by the class String. When the intern method is invoked...
String##intern()源码 先来看一下intern()方法的JDK源码如下:/** * Returns a canonical representation for the string object. * * A pool of strings, initially empty, is maintained privately by the * class {@code String}. * * When the intern method is invoked, if the pool already conta...
* class {@code String}. * * When the intern method is invoked, if the pool already contains a * string equal to this {@code String} object as determined by * the {@link #equals(Object)} method, then the string from the pool is * returned...
classString. When the intern method is invoked, if the pool already contains a string equal to thisStringobject as determined by the {@link #equals(Object)} method, then the string from the pool is returned. Otherwise, thisStringobject is added to the pool ...
String.intern()方法解析 String、StringBuffer与StringBuilder String概览 在Java中,所有类似“ABCabc”的字面值,都是String的实例;String类位于java.lang包下,是Java语言的核心类,提供了字符串的比较、查找、截取、大小写转换等操作;Java语言为“+”连接符以及对象转换为字符串提供了特殊支持,字符串对象可以使用“+”...
String b=newStringBuffer("a").append("a").toString(); System.out.println(a==b); // falseif(a.intern() ==a) { //true System.out.println("intern method was == the first object"); } System.out.println(a.intern()==b); //false ...
当字符串是不可变时,字符串常量池才有意义。字符串常量池的出现,可以减少创建相同字面量的字符串,让不同的引用指向池中同一个字符串,为运行时节约很多的堆内存。若字符串可变,字符串常量池失去意义,基于常量池的String.intern()方法也失效,每次创建新的 String 将在堆内开辟出新的空间,占据更多的内存。