fork(4) download
  1. /* package whatever; // don't place package name! */
  2.  
  3. import java.util.*;
  4. import java.lang.*;
  5. import java.io.*;
  6.  
  7. /* Name of the class has to be "Main" only if the class is public. */
  8. class Ideone
  9. {
  10. public static void main (String[] args) throws java.lang.Exception
  11. {
  12.  
  13. // Mysteriously, `UUID.randomUUID` times-out here on IdeOne.com.
  14. // So, copy-paste a hex-string representing the 128-bits of a UUID, feed to `UUID.fromString`.
  15.  
  16. // For your convenience, generate such a hex string at this web site:
  17. // https://w...content-available-to-author-only...r.net/version1
  18.  
  19. UUID uuid = UUID.fromString( "fcd70f82-c80f-11e8-a8d5-f2801f1b9fd1" ) ;
  20.  
  21. int hash1 = uuid.hashCode();
  22. int hash2 = Objects.hashCode( uuid ); // Result matches line above.
  23.  
  24. int hash3 = Objects.hash( uuid ); // Returns a hash of a hash.
  25. int hash4 = Objects.hash( uuid.hashCode() ); // Result matches line above.
  26.  
  27. System.out.println( "uuid.toString(): " + uuid.toString() );
  28. System.out.println( " 1/2 = " + hash1 + " | " + hash2 );
  29. System.out.println( " 3/4 = " + hash3 + " | " + hash4 );
  30.  
  31.  
  32. }
  33. }
Success #stdin #stdout 0.04s 2184192KB
stdin
Standard input is empty
stdout
uuid.toString(): fcd70f82-c80f-11e8-a8d5-f2801f1b9fd1
 1/2 = -2095680709 | -2095680709
 3/4 = -2095680678 | -2095680678