这两个陈述之间有什么区别?
String s = "text";
String s = new String("text");
Run Code Online (Sandbox Code Playgroud) String s1 = new String("string");
String s2 = new String("string");
String s3 = "string";
String s4 = "string";
System.out.println(s1 == s2); //FALSE
System.out.println(s2.equals(s1)); //TRUE
System.out.println(s3 == s4); //TRUE
System.out.println(s3.equals(s4)); //TRUE
Run Code Online (Sandbox Code Playgroud)
创造s1和有s3什么区别?请告诉我
在String中我们只有String对象,那么为什么它以不同的方式处理这两个.s1和s2具有不同的存储器地址,而s3和s4具有相同的存储器地址.为什么它基于new运营商.