Android Guides | Samples

Java.Lang.String.Intern Method

Returns an interned string equal to this string.


[Android.Runtime.Register("intern", "()Ljava/lang/String;", "")]
public String Intern ()


Returns an interned string equal to this string. The VM maintains an internal set of unique strings. All string literals found in loaded classes' constant pools are automatically interned. Manually-interned strings are only weakly referenced, so calling intern won't lead to unwanted retention.

Interning is typically used because it guarantees that for interned strings a and b, a.equals(b) can be simplified to a == b. (This is not true of non-interned strings.)

Many applications find it simpler and more convenient to use an explicit JavaDictionary to implement their own pools.

[Android Documentation]


Namespace: Java.Lang
Assembly: Mono.Android (in Mono.Android.dll)
Assembly Versions:
Since: Added in API level 1