Java String intern()方法示例。
String类的 intern()方法返回字符串对象的规范表示。因此,对于任意两个字符串s和t,当且仅当s.equals(t)为true时,s.intern()==t.intern()为true。
示例
import java.io.*;
public class Test {
public static void main(String args[]) {
String Str1 = new String("Welcome to Nhooo.com");
String Str2 = new String("WELCOME TO SUTORIALSPOINT.COM");
System.out.print("规范表示:" );
System.out.println(Str1.intern());
System.out.print("规范表示:" );
System.out.println(Str2.intern());
}
}输出结果
规范表示: Welcome to Nhooo.com 规范表示: WELCOME TO SUTORIALSPOINT.COM
热门推荐
10 上班贺卡祝福语简短精辟
11 结婚祝福语嫂子的话简短
12 祝寺院师傅祝福语简短
13 高中送红包祝福语简短
14 老师迟到生日祝福语简短
15 女儿爸爸婚礼祝福语简短
16 直系离职祝福语大全简短
17 粤语父母婚礼祝福语简短
18 花篮考学祝福语大全简短