Created
December 21, 2016 17:48
-
-
Save agustarc/abf35cfc7be059b4c1d2756da62224df to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class StringMemoryIntern { | |
public static void main(String... args) { | |
String literal = "loper"; | |
String object = new String("loper"); | |
String intern = object.intern(); | |
System.out.println(literal == object); // false | |
System.out.println(literal.equals(object)); // true | |
System.out.println(literal == intern); // true | |
System.out.println(literal.equals(intern)); // true | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment