String 引用于地址
package interview;
public class TestString {
public static void main(String[] args) {
//"abc"在字符串库中没有abc 的情况下是相当与new String () + 赋值= 两个过程
//但是字符串库中存在abc 时候是就没有new String () 这过程;
String s1 = "abc";
String s2 = "abc";
int i = s1.hashCode();
int i1 = s2.hashCode();
System.out.println(i + "\t" + i1);
String s3 = new String("abc");
String s4 = new String("abc");
int j1 = s3.hashCode();
int j2 = s4.hashCode();
System.out.println(j1 + "\t" + j2);
System.out.println(s3.hashCode());
System.out.println(System.identityHashCode(s3));
System.out.println(System.identityHashCode(s4));
System.out.println(System.identityHashCode(s1));
System.out.println(System.identityHashCode(s2));
}}