BigInteger hashCode() Method in Java Last Updated : 14 Aug, 2018 Comments Improve Suggest changes Like Article Like Report The java.math.BigInteger.hashCode() method returns the hash code for this BigInteger. The hashcode is always the same if the object doesn't change. Hashcode is a unique code generated by the JVM at the time of object creation. We can use hashcode to perform some operation on hashing related algorithms like hashtable, hashmap etc. We can search an object with that unique code. Syntax: public int hashCode() Returns: The method returns an integer value which represents hashCode value for this BigInteger. Examples: Input: BigInteger1=32145 Output: 32145 Explanation: BigInteger1.hashCode()=32145. Input: BigInteger1=7613721467324 Output: -1255493552 Explanation: BigInteger1.hashCode()=-1255493552. Example 1: Below programs illustrate hashCode() method of BigInteger class Java // Java program to demonstrate // hashCode() method of BigInteger import java.math.BigInteger; public class GFG { public static void main(String[] args) { // Creating 2 BigInteger objects BigInteger b1, b2; b1 = new BigInteger("32145"); b2 = new BigInteger("7613721467324"); // apply hashCode() method int hashCodeOfb1 = b1.hashCode(); int hashCodeOfb2 = b2.hashCode(); // print hashCode System.out.println("hashCode of " + b1 + " : " + hashCodeOfb1); System.out.println("hashCode of " + b2 + " : " + hashCodeOfb2); } } Output: hashCode of 32145 : 32145 hashCode of 7613721467324 : -1255493552 Example 2: When both bigInteger has same value Java // Java program to demonstrate // hashCode() method of BigInteger import java.math.BigInteger; public class GFG { public static void main(String[] args) { // Creating 2 BigInteger objects BigInteger b1, b2; b1 = new BigInteger("4326516236135"); b2 = new BigInteger("4326516236135"); // apply hashCode() method int hashCodeOfb1 = b1.hashCode(); int hashCodeOfb2 = b2.hashCode(); // print hashCode System.out.println("hashCode of " + b1 + " : " + hashCodeOfb1); System.out.println("hashCode of " + b2 + " : " + hashCodeOfb2); } } Output: hashCode of 4326516236135 : 1484200280 hashCode of 4326516236135 : 1484200280 Reference: BigInteger hashCode() Docs Comment More infoAdvertise with us Next Article BigInteger hashCode() Method in Java A AmanSingh2210 Follow Improve Article Tags : Java java-basics Java-BigInteger Practice Tags : JavaJava-BigInteger Similar Reads BigDecimal hashCode() Method in Java The java.math.BigDecimal.hashCode() returns the hash code for this BigDecimal. The hashcode will generally not be the same for two BigDecimal objects with equal values and different scale (like 4743.0 and 4743.00). Syntax: public int hashCode() Parameters: This method does not accept any parameters. 2 min read GregorianCalendar hashCode() Method in Java The java.util.GregorianCalendar.hashCode() is an in-built function in Java which generates hash code for this GregorianCalendar instance. Syntax: public int hashCode() Parameters: This function does not accept any parameters. Return Values: This function returns an integer value which represents the 2 min read Set hashCode() Method in Java In Java, the hashCode() method is defined in the Object class and is used to generate a hash code for objects. It plays a very important role in hash-based collections like HashMap, HashSet, and HashTable. Example 1: This example demonstrates how hashCode() is used to get the hash code of the HashSe 2 min read BitSet hashCode Method in Java with Examples The hashCode() Method of BitSet class in Java is used to fetch the hash code value of a particular this BitSet. This returned hash codes value depends on the set bits of the bit set being passed. Syntax: BitSet.hashCode() Parameters: The method does not accept any parameters. Return Value: The metho 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 Java AbstractMap hashCode() Method The hashCode() method of the AbstractMap class in Java is used to calculate a hash code value for a map. This hash code is based on the key-value mapping contained in the map. It ensures consistency such that two maps with the same entries have the same hash code.Example 1: Hash Code of a Non-Empty 2 min read Java AbstractSet hashCode() Method The hashCode() method in AbstractSet (and its subclasses like HashSet) computes a hash code based on the elements of the set. It ensures that if two sets contain the same elements, their hash codes will be the same, provided the elements themselves return consistent hash codes.Working of Hash Code:T 3 min read DecimalFormat hashCode() method in Java The hashCode() method is a built-in method of the java.text.DecimalFomrat class in Java and is used to get an integral hashCode value for this DecimalFormat instance. Syntax: public int hashCode() Parameters: The function does not accepts any parameter. Return Value: The function returns an integral 1 min read Vector hashCode() Method in Java The java.util.vector.hashCode() method in Java is used to get the hashcode value of this vector. Syntax: Vector.hashCode() Parameters: The method does not take any parameter. Return Value: The method returns hash code value of this Vector which is of Integer type. Below programs illustrate the Java. 2 min read CopyOnWriteArrayList hashCode() method in Java The hashCode() method of CopyOnWriteArrayList returns the hashCode value of the list. Syntax: public int hashCode() Parameters: The function does not accepts any parameter. Return Value: The function returns the hashCode value of the list. Below programs illustrate the above function: Program 1: Jav 1 min read Like