Constructor hashCode() method in Java with Examples Last Updated : 29 Oct, 2019 Comments Improve Suggest changes Like Article Like Report The hashCode() method of java.lang.reflect.Constructor class is used to return a hashcode for this Constructor object. The hashcode is always the same if the constructed object doesn’t change. Hashcode is a unique code generated by the JVM at the time of class object creation. We can use hashcode to perform some operation on hashing related algorithms like a hashtable, hashmap, etc. We can search for an object with that unique code. Syntax: public int hashCode() Parameters: This method accepts nothing. Return: This method returns a hash code integer value for this object. Below programs illustrate hashCode() method: Program 1: Java // Java program to illustrate hashCode() method import java.lang.reflect.Constructor; import java.util.ArrayList; public class GFG { public static void main(String[] args) { // create a class object Class classObj = ArrayList.class; // get Constructor object // array from class object Constructor[] cons = classObj.getConstructors(); // get hash code of this constructor class int code = cons[0].hashCode(); // print result System.out.println( "Hash Code count = " + code); } } Output: Hash Code count = -1114099497 Program 2: Java // Java program to illustrate hashCode() method import java.lang.reflect.Constructor; public class GFG { public static void main(String[] args) { // create a class object Class classObj = String.class; // get Constructor object // array from class object Constructor[] cons = classObj.getConstructors(); // get hash code of this constructor class int code = cons[0].hashCode(); // print result System.out.println( "Hash Code count for string class" + " constructor = " + code); } } Output: Hash Code count for string class constructor = 1195259493 References: https://docs.oracle.com/javase/10/docs/api/java/lang/reflect/Constructor.html#hashCode() Comment More infoAdvertise with us Next Article Constructor hashCode() method in Java with Examples A AmanSingh2210 Follow Improve Article Tags : Java Java-Constructors Java-Functions java-lang-reflect-package Practice Tags : Java Similar Reads Collator hashCode() method in Java with Example The hashCode() method of java.text.Collator class is used to get the hashCode for this Collator object. Syntax: public abstract int hashCode() Parameter: This method does not accept any parameter.Return Value: This method returns hash code value in integer format. Below are the examples to illustrat 2 min read Class hashCode() method in Java with Examples The hashCode() method of java.lang.Class class is used to get the hashCode representation of this entity. This method returns an integer value which is the hashCode. Syntax: public int hashCode() Parameter: This method does not accept any parameter. Return Value: This method returns an integer value 1 min read AbstractList hashCode() method in Java with Examples The hashCode() method of java.util.AbstractList class is used to return the hash code value for this list. Syntax: public int hashCode() Returns Value: This method returns the hash code value for this list. Below are the examples to illustrate the hashCode() method. Example 1: Java // Java program t 2 min read Charset hashCode() method in Java with Examples The hashCode() method is a built-in method of the java.nio.charset returns the computed hashcode of any given charset. Syntax: public final int hashCode() Parameters: The function does not accepts any parameter. Return Value: The function returns the computed hashcode for the charset. Below is the i 1 min read ChoiceFormat hashCode() method in Java with Examples The hashCode() method of java.text.ChoiceFormat class is used to get the hash code for choice format object. This hashcode value is returned as an integer. Syntax: public int hashCode() Parameter: This method does not accept any parameter. Return Value: This method returns hash code for choice forma 2 min read Like