Character.hashCode() has the following syntax.
public int hashCode()
In the following code shows how to use Character.hashCode() method.
//from ww w. java 2 s . co m public class Main { public static void main(String[] args) { Character c1 = new Character('z'); Character c2 = new Character('Z'); int i1 = c1.hashCode(); int i2 = c2.hashCode(); String str1 = "Hashcode of " + c1 + " is " + i1; String str2 = "Hashcode of " + c2 + " is " + i2; System.out.println(str1); System.out.println(str2); } }
The code above generates the following result.