Skip to content

Instantly share code, notes, and snippets.

@vaskoz
Last active December 15, 2015 21:49
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save vaskoz/5328607 to your computer and use it in GitHub Desktop.
Save vaskoz/5328607 to your computer and use it in GitHub Desktop.
Compare Java hashing functions between JVM invocations. NOTE: This example will only run on Java 7.
public class Hash {
public static void main(String[] args) {
String str = "Java Programming Language";
System.out.println(str + " hashCode(): "
+ str.hashCode()
+ " new Java 7 hashCode used by collections: "
+ sun.misc.Hashing.stringHash32(str));
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment