...
- The cost of
String.intern()
grows as the number of intern strings grows. Performance should be no worse than n log n, but the Java Language Specification makes no guarantee. - Strings that have been interned become immortal: they cannot be garbage collected. This can be problematic when large numbers of strings are interned.
Exceptions
EXP01-EX1EX0: Using reference equality in place of object equality is permitted only when the defining classes guarantee the existence of, at most, one object instance for each possible object value. This generally requires that instances of such classes are immutable. The use of static factory methods, rather than public constructors, facilitates instance control; this is a key enabling technique.
Wiki Markup |
---|
Objects that are instances of classes that provide this guarantee obey the invariant that, for any two references {{a}} and {{b}}, {{a.equals(b)}} is exactly equivalent to {{a == b}} \[[Bloch 2008|AA. Bibliography#Bloch 08]\]. The {{String}} class does not meet these requirements and, consequently, does not obey this invariant. |
EXP01-EX2EX1: Use reference equality to determine whether two references point to the same object.
...
<ac:structured-macro ac:name="unmigrated-wiki-markup" ac:schema-version="1" ac:macro-id="a94bf4455c278463-57a70483-4bf4451e-83c5acc9-377a6b169c5a25009933f5ad"><ac:plain-text-body><![CDATA[ | [[FindBugs 2008 | AA. Bibliography#FindBugs 08]] | ES: Comparison of String objects using == or != | ]]></ac:plain-text-body></ac:structured-macro> | |
<ac:structured-macro ac:name="unmigrated-wiki-markup" ac:schema-version="1" ac:macro-id="bcfb85475157a43d-ab9a0d5e-45cb4007-ba7a8f95-21617c1d1ee196060d51ba05"><ac:plain-text-body><![CDATA[ | [[JLS 2005 | AA. Bibliography#JLS 05]] | [§3.10.5, "String Literals" | http://java.sun.com/docs/books/jls/third_edition/html/lexical.html#3.10.5] | ]]></ac:plain-text-body></ac:structured-macro> |
|
...