Java-string-intern
提供:Dev Guides
Java-String intern()メソッド
説明
このメソッドは、文字列オブジェクトの正規表現を返します。 つまり、任意の2つの文字列 s および t について、s.equals(t)がtrueの場合にのみ、s.intern()== t.intern()はtrueです。
構文
このメソッドの構文は次のとおりです-
public String intern()
パラメーター
ここにパラメータの詳細があります-
- これはデフォルトの方法であり、パラメーターを受け入れません。
戻り値
- このメソッドは、文字列オブジェクトの正規表現を返します。
例
import java.io.*;
public class Test {
public static void main(String args[]) {
String Str1 = new String("Welcome to finddevguides.com");
String Str2 = new String("WELCOME TO SUTORIALSPOINT.COM");
System.out.print("Canonical representation:" );
System.out.println(Str1.intern());
System.out.print("Canonical representation:" );
System.out.println(Str2.intern());
}
}
これは、次の結果を生成します-
出力
Canonical representation: Welcome to finddevguides.com
Canonical representation: WELCOME TO SUTORIALSPOINT.COM