Skip to content

String 详解

常量池

java
public class StringTest {

    @Test
    public void test1() {
        String s1 = "abc";
        String s2 = new String("abc");
        String s3 = s2.intern();
        System.out.println(s1 == s2);
        System.out.println(s2 == s3);
        System.out.println(s1 == s3);
    }
}