ParsePosition hashCode() method in Java with Example Last Updated : 20 Jan, 2023 Comments Improve Suggest changes Like Article Like Report The hashCode() method of java.text.ParsePosition class is used to retrieve the hash code for the current parse position object. Syntax: public int hashCode() Parameter: This method does not accepts any argument as parameter. Return Value: This method returns the hash code for the current parse position object. 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 ParsePosition Object ParsePosition pos = new ParsePosition(500); // getting hashCode for // current ParsePosition Object // using hashcode() method int i = pos.hashCode(); // display result System.out.println( "hashCode: " + Integer.toString(i)); } catch (ClassCastException e) { System.out.println(e); } } } Output:hashCode: -65036 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 // new ParsePosition Object ParsePosition pos = new ParsePosition(-1); // getting hashCode for // current ParsePosition Object // using hashCode() method int i = pos.hashCode(); // display result System.out.println( "hashCode: " + Integer.toString(i)); } catch (ClassCastException e) { System.out.println(e); } } } Output:hashCode: -1 Reference: https://docs.oracle.com/javase/9/docs/api/java/text/ParsePosition.html#hashCode-- Comment More infoAdvertise with us Next Article ParsePosition hashCode() method in Java with Example R rohitprasad3 Follow Improve Article Tags : Java Java-Functions Java-text package Java-ParsePosition Practice Tags : Java Similar Reads Optional hashCode() method in Java with examples The hashCode() method of java.util.Optional class in Java is used to get the hashCode value of this Optional instance. If there is no value present in this Optional instance, then this method returns 0. Syntax: public int hashCode() Parameter: This method do not accepts any parameter. Return Value: 1 min read TreeSet hashCode() method in Java with Example The hashCode() method of TreeSet in Java is used to get the hashCode value for this instance of the TreeSet. It returns an integer value which is the hashCode value for this instance of the TreeSet. Syntax: public int hashCode() Parameters: This function has no parameters. Returns: The method return 2 min read Path hashCode() method in Java with Examples The Java Path interface was added to Java NIO in Java 7. hashCode() method of java.nio.file.Path used to return a hash code for this path after computing hashcode. The hashcode is always the same if the object doesnât change. Hashcode is a unique code generated by the JVM at time of object creation. 2 min read Period hashCode() method in Java with Examples The hashCode() method of Period class in Java is used to get the generated hashCode for this period. Syntax: public int hashCode() Parameters: This method does not accepts any parameter. Return Value: This method returns the hashCode generated for the given period. Below programs illustrate the hash 2 min read Properties hashCode() method in Java with Examples The hashCode() method of Properties class is used to generate a hashCode for the given Properties containing key and values. Syntax: public int hashCode() Parameters: This method has no argument. Returns: This method returns the hashCode value for the given map. Below programs show the implementatio 2 min read Like