Example For Finding The hashCode of a character in java

Example For Finding The hashCode of a character in java


Posted in : Core Java Posted on : October 1, 2010 at 3:44 PM Comments : [ 0 ]

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

Download This Example.

Go to Topic «PreviousHomeNext»

Your Comment:


Your Name (*) :
Your Email :
Subject (*):
Your Comment (*):
  Reload Image
 
 

 
Tutorial Topics