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
热门推荐
3 庆双节祝福语简短
8 十月简短祝福语
10 祝妹妹毕业祝福语简短
11 生日祝福语 简短独特高考
12 上嫂子生日祝福语简短
13 职场祝福语大全 简短精辟
14 三八简短祝福语给婆婆
15 给长辈祝福语简短大全
16 牛年女神节祝福语简短
17 婶婶生日贺词简短祝福语
18 老人过大寿祝福语简短