public class String001 { public static void main(String[] args) { String s1 = "hello"; String s2 = new String("hello"); String s3 = new String("hello").intern(); System.out.println(s1 == s2); //false System.out.println(s1 == s3); //true } }
2024-03-31 09:35:40
public class String001 { public static void main(String[] args) { String s1 = "hello"; String s2 = new String("hello"); String s3 = new String("hello").intern(); System.out.println(s1 == s2); //false System.out.println(s1 == s3); //true } }