MonthDay hashCode() method in Java with Examples Last Updated : 11 Apr, 2023 Comments Improve Suggest changes Like Article Like Report 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 hashtable, hashmap etc. An object can also be searched with its unique code (hashcode). Syntax: public int hashCode() Parameters: This method did not accepts any parameter. Return value: This method returns a suitable hash code. Below programs illustrate the hashCode() method: Program 1: Java // Java program to demonstrate // MonthDay.hashCode() method import java.time.*; public class GFG { public static void main(String[] args) { // create a MonthDay object MonthDay month = MonthDay.parse("--10-12"); // print hashcode System.out.println("hashCode" + " of YearMonth: " + month.hashCode()); } } Output:hashCode of YearMonth: 652 Program 2: Java // Java program to demonstrate // MonthDay.hashcode() method import java.time.*; public class GFG { public static void main(String[] args) { // create a MonthDay object MonthDay month = MonthDay.parse("--08-31"); // print hashcode System.out.println("hashCode" + " of YearMonth: " + month.hashCode()); } } Output:hashCode of YearMonth: 543 References: https://docs.oracle.com/javase/10/docs/api/java/time/MonthDay.html#hashCode() Comment More infoAdvertise with us Next Article MonthDay hashCode() method in Java with Examples A AmanSingh2210 Follow Improve Article Tags : Java java-basics Java-Functions Java-time package Java-MonthDay +1 More Practice Tags : Java Similar Reads 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 SortedMap hashCode() method in Java with Examples The hashCode() method of SortedMap interface in Java is used to generate a hashCode for the given map containing key and values. Syntax: int hashCode() Parameters: This method has no argument. Returns: This method returns the hashCode value for the given map. Note: The hashCode() method in SortedMap 2 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 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 UUID hashCode() Method in Java with Examples 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 progra 1 min read Like