Created
May 16, 2016 09:01
-
-
Save mwkang/8d36e7ad5595efaf3532efec10cc4f64 to your computer and use it in GitHub Desktop.
test for interned strings
This file contains hidden or 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
| { | |
| List<String> set = Lists.newArrayList(); | |
| for (int i = 0; i < 5; i++) { | |
| String a = new String("a"); | |
| String b = "a"; | |
| System.out.println(System.identityHashCode(a)); | |
| System.out.println(System.identityHashCode(b)); | |
| set.add("c"); | |
| System.out.println("?? =====> " + System.identityHashCode(set.get(0))); | |
| set.clear(); | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment