UUID hashCode() Method in Java with Examples Last Updated : 27 Dec, 2018 Comments Improve Suggest changes Like Article Like Report The hashCode() method of UUID class in Java is generally used to get the hash code value of the UUID. Syntax: public int hashCode() Parameters: This method does not take any parameter. Return Value: This method returns an integer value which is the hashCode value for this UUID instance. Below programs illustrate the working of hashCode() method: Program 1: Java // Java code to illustrate hashCode() method import java.util.*; public class UUID_Demo { public static void main(String[] args) { // Creating two UUIDs UUID UUID_1 = UUID .fromString( "58e0a7d7-eebc-11d8-9669-0800200c9a66"); // Displaying the UUID System.out.println("UUID: " + UUID_1); // Displaying the hashCode value System.out.println("The hashCode value is: " + UUID_1.hashCode()); } } Output: UUID: 58e0a7d7-eebc-11d8-9669-0800200c9a66 The hashCode value is: 3744873 Program 2: Java // Java code to illustrate hashCode() method import java.util.*; public class UUID_Demo { public static void main(String[] args) { // Creating two UUIDs UUID UUID_1 = UUID .fromString( "5fc03087-d265-11e7-b8c6-83e29cd24f4c"); // Displaying the UUID System.out.println("UUID: " + UUID_1); // Displaying the hashCode Value System.out.println("The hashCode value is: " + UUID_1.hashCode()); } } Output: UUID: 5fc03087-d265-11e7-b8c6-83e29cd24f4c The hashCode value is: -1447957042 Comment More infoAdvertise with us Next Article UUID hashCode() Method in Java with Examples C chinmoy lenka Follow Improve Article Tags : Misc Java Java - util package Java-Functions Java-UUID +1 More Practice Tags : JavaMisc Similar Reads Period hashCode() method in Java with Examples The hashCode() method of Period class in Java is used to get the generated hashCode for this period. Syntax: public int hashCode() Parameters: This method does not accepts any parameter. Return Value: This method returns the hashCode generated for the given period. Below programs illustrate the hash 2 min read Path hashCode() method in Java with Examples The Java Path interface was added to Java NIO in Java 7. hashCode() method of java.nio.file.Path used to return a hash code for this path after computing hashcode. The hashcode is always the same if the object doesnât change. Hashcode is a unique code generated by the JVM at time of object creation. 2 min read MonthDay hashCode() method in Java with Examples hashCode() method of the MonthDay class used to get hashCode for this MonthDay. The hashcode is always the same if the object doesnât change. Hashcode is a unique code generated by the JVM at time of object creation. It can be used to perform some operation on hashing related algorithm like a hashta 1 min read Short hashCode() method in Java with Examples The hashCode() method of Short class is a built in method in Java which is used to return the hash code of the ShortObject. Note: The hashCode() returns the same value as intValue(). Syntax ShortObject.hashCode() Return Value: It return an int value which represents the hashcode of the specified Sho 2 min read Optional hashCode() method in Java with examples The hashCode() method of java.util.Optional class in Java is used to get the hashCode value of this Optional instance. If there is no value present in this Optional instance, then this method returns 0. Syntax: public int hashCode() Parameter: This method do not accepts any parameter. Return Value: 1 min read Like