Character.hashCode() in Java with examples Last Updated : 06 Dec, 2018 Summarize Comments Improve Suggest changes Share Like Article Like Report Java.lang.Character.hashCode() is a built-in method in Java which returns a hash code for this Character. The returned hash code is equal to the result of invoking charValue(). Syntax: public int hashCode() This function does not accepts any parameter. Return Value: This method returns a hash code value for this Character. Below programs illustrate the Java.lang.Character.hashCode() function: Program 1: Java // Java program to demonstrate the // function when the value passed in the parameter // is a character import java.lang.*; public class Gfg { public static void main(String[] args) { // parameter ch char ch = 'B'; // assigns character values Character c = Character.valueOf(ch); // assign hashcodes of c1, c2 to i1, i2 int i = c.hashCode(); // prints the character values System.out.println("Hashcode of " + ch + " is " + i); } } Output: Hashcode of B is 66 Program 2: Java // Java program to demonstrate the // function when the value passed in the parameter // is a number import java.lang.*; public class Gfg { public static void main(String[] args) { // parameter ch char ch = '6'; // assigns character values Character c = Character.valueOf(ch); // assign hashcodes of ch int i = c.hashCode(); // prints the character values System.out.println("Hashcode of " + ch + " is " + i); } } Output: Hashcode of 6 is 54 Comment More infoAdvertise with us Next Article Date hashCode() method in Java with Examples T Twinkl Bajaj Follow Improve Article Tags : Misc Java Java-lang package Java-Functions Java-Character +1 More Practice Tags : JavaMisc Similar Reads 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 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 Constructor hashCode() method in Java with Examples 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 2 min read Calendar hashCode() Method in Java with Examples The hashCode() method in Calendar class is used to return the hash code for this Calendar Object.Syntax: public int hashCode() Parameters: The method does not take any parameters.Return Value: The method returns the hash code value for this calendar object..Below programs illustrate the working of h 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 Like