In this Example, We introduce you about the hashCode() method for finding the hash code of characters.
Example For Finding The hashCode of a character in java
In this Example, We introduce you about the hashCode() method of the Object class. This method returns the hashCode value for the character. The hashCde() method is used with the character object followed by .(dot) operator.
Example: CharacterHashCode.java
package com.devmanuals; public class CharacterHashCode { public static void main(String[] args) { Character ch1 = new Character('a'); Character ch2 = new Character('A'); System.out.print("The hash code of character a is= "); System.out.println(ch1.hashCode()); System.out.print("The hash code of character A is= "); System.out.println(ch2.hashCode()); } }
Output:
The hash code of character a is= 97 The hash code of character A is= 65 |
[ 0 ] Comments