Collator hashCode() method in Java with Example Last Updated : 30 Sep, 2021 Comments Improve Suggest changes Like Article Like Report The hashCode() method of java.text.Collator class is used to get the hashCode for this Collator object. Syntax: public abstract int hashCode() Parameter: This method does not accept any parameter.Return Value: This method returns hash code value in integer format. Below are the examples to illustrate the hashCode() method: Example 1: Java // Java program to demonstrate // hashCode() method import java.text.*; import java.util.*; import java.io.*; public class GFG { public static void main(String[] argv) { try { // Creating and initializing new simple rule String simple = "< a < b < c < d"; // Creating and initializing // new RuleBasedCollator Object RuleBasedCollator col = new RuleBasedCollator(simple); // getting hashCode of this object // using hashCode() method int hash = col.hashCode(); // display result System.out.println("hashCode is :- " + hash); } catch (ClassCastException e) { System.out.println("Exception thrown : " + e); } catch (ParseException e) { System.out.println("Exception thrown : " + e); } } } Output: hashCode is :- 1882448026 Example 2: Java // Java program to demonstrate // hashCode() method import java.text.*; import java.util.*; import java.io.*; public class GFG { public static void main(String[] argv) { try { // Creating and initializing Collator Object Collator col = Collator.getInstance(Locale.UK); // getting hashCode of this object // using hashCode() method int hash = col.hashCode(); // display result System.out.println("hashCode is :- " + hash); } catch (ClassCastException e) { System.out.println("Exception thrown : " + e); } } } Output: hashCode is :- 681002966 Reference: https://docs.oracle.com/javase/9/docs/api/java/text/Collator.html#hashCode-- Comment More infoAdvertise with us Next Article Collator hashCode() method in Java with Example rohitprasad3 Follow Improve Article Tags : Java Java-Functions Java-text package Java-Collator Practice Tags : Java Similar Reads 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 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 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 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 Boolean hashCode() method in Java with examples The hashCode() method of Boolean class is a built in method to return a int hashcode value corresponding to the Boolean object. Syntax BooleanObject.hashCode() Return Type: It returns a int hashcode value corresponding to the Boolean object. It returns 1231 if the Boolean object stores the value tru 1 min read Double hashCode() method in Java with examples The hashCode() method of Double class is a built-in method use to return the hashcode value of this Double object. Syntax: DoubleObject.hashCode() Parameters: It takes no parameters. Return Type: It returns an int value. The value returned is (int)(v^(v>>>32)) where v is a long variable equ 1 min read Duration hashCode() method in Java with Examples The hashCode() method of Duration Class in java.time package is used to get the hashCode value of this duration. Syntax: public int hashCode() Parameters: This method do not accepts any parameter. Return Value: This method returns an int value which is the hashCode value of this duration. Below exam 1 min read ChronoLocalDate hashCode() method in Java with Examples The hashCode() method of ChronoLocalDate interface in Java is used to get the hashCode value of this ChronoLocalDate object in the integer form. Syntax: public int hashCode() Parameter: This method does not accepts any parameter. Return Value: The function returns a suitable hash code in the form of 1 min read DateFormat hashCode() method in Java with Examples The hashCode() Method of DateFormat class is used to return the hash code value of this DateFormat object. The hash code is of integer type. Syntax: public int hashCode() Parameters: The method does not take any parameters. Return Value: The method returns the hash code value of this DateFormat obje 2 min read Like