Skip to content

Instantly share code, notes, and snippets.

@mwkang
Created May 16, 2016 09:01
Show Gist options
  • Select an option

  • Save mwkang/8d36e7ad5595efaf3532efec10cc4f64 to your computer and use it in GitHub Desktop.

Select an option

Save mwkang/8d36e7ad5595efaf3532efec10cc4f64 to your computer and use it in GitHub Desktop.
test for interned strings
{
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