Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- String s1 = "hello!";
- String s2 = "hello!";
- String s3 = "hello!".intern();
- String s4 = new String("hello!");
- String s5 = "lo";
- System.out.println("s1 == s2 " + (s1 == s2)); // true
- System.out.println("s1 == s3 " + (s1 == s3)); // true
- System.out.println("s1 == s4 " + (s1 == s4)); // false
- System.out.println("s1 == s4.intern() " + (s1 == s4.intern())); // true
- System.out.println("s1 == \"hel\" + \"lo!\": " + (s1 == "hel" + "lo!")); // true
- System.out.println("s1 == \"hel\" + s5: " + (s1 == "hel" + s5)); // false
Advertisement
Add Comment
Please, Sign In to add comment