Year hashCode() method in Java with Examples Last Updated : 27 Nov, 2018 Comments Improve Suggest changes Like Article Like Report The hashCode() method of Year class in Java is used to get a suitable hash code for the current Year object. Syntax: public int hashCode() Parameter: This method does not accepts any parameter. Return Value: It returns a suitable integral hash code for the year object with which it is used. It never returns a NULL value. Below programs illustrate the hashCode() method of Year in Java: Program 1: Java // Program to illustrate the hashCode() method import java.util.*; import java.time.*; public class GfG { public static void main(String[] args) { // Creates a Year object Year firstYear = Year.of(1997); // Print the hash code for // the current year object System.out.println(firstYear.hashCode()); } } Output: 1997 Program 2: Java // Program to illustrate the hashCode() method import java.util.*; import java.time.*; public class GfG { public static void main(String[] args) { // Creates a Year object Year firstYear = Year.of(2018); // Print the hash code for // the current year object System.out.println(firstYear.hashCode()); } } Output: 2018 Reference: https://docs.oracle.com/javase/8/docs/api/java/time/Year.html#hashCode-- Comment More infoAdvertise with us Next Article Year hashCode() method in Java with Examples B barykrg Follow Improve Article Tags : Misc Java Java-Functions Java-time package Java-Year +1 More Practice Tags : JavaMisc Similar Reads Writer hashCode() method in Java with Example The hashCode() method of Writer Class in Java is used to get the HashCode value of this Writer instance. This method does not accepts any parameter and returns the required int value. Syntax: public int hashCode() Parameters: This method accepts does not accepts any parameter. Return Value: This met 2 min read Year get() method in Java with Examples get() method of the Year class used to get the value for the specified field passed as parameter from this Year as an integer value. This method queries this year for the value of the field and the returned value will always be within the valid range of values for the field. When the field is not su 2 min read List hashCode() Method in Java with Examples This method is used to generate the hashCode for the given list. Implementation:Java// Java code to show the implementation of // hashCode method in list interface import java.util.*; public class Main { public static void main(String[] args) { // Initializing a list List<Integer> l = new Arra 2 min read Date hashCode() method in Java with Examples The hashCode() method of Java Date class returns a value which is a hash code for this object. Syntax: public int hashCode() Parameters: The function does not accept any parameter. Return Value: It returns a hashCode value for this object. Exception: The function does not throws any exception. Progr 2 min read Byte hashCode() method in Java with examples The hashCode() method of Byte class is a built in method in Java which is used to return the hash code of the ByteObject. Note: The hashCode() returns the same value as intValue(). Syntax ByteObject.hashCode() Return Value: It return an int value which represents the hashcode of the specified Byte o 2 min read Like