String类型内存转换,你明白为什么吗?

package learnIng;

public class StringTest {
    public static void main(String[] args) {
        String a = "a";
        String b = "a";
        String c = new String("a");
        String d=c.intern();
        System.out.println(a.equals(b));
        System.out.println(a == b);
        System.out.println("------------");
        System.out.println(a.equals(c));
        System.out.println(a == c);
        System.out.println("------------");
        System.out.println(a.equals(d));
        System.out.println(a == d);
    }
}

实验结果:
true
true


true
false


true
true
能否知道为什么?

相关推荐
©️2020 CSDN 皮肤主题: Age of Ai 设计师:meimeiellie 返回首页