Properties hashCode() method in Java with Examples Last Updated : 30 Sep, 2019 Comments Improve Suggest changes Like Article Like Report 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 implementation of int hashCode() method. Program 1: Java // Java code to show the implementation of // hashCode method import java.util.*; public class GfG { // Main method public static void main(String[] args) { // Create a properties and add some values Properties properties = new Properties(); properties.put("Pen", 10); properties.put("Book", 500); properties.put("Clothes", 400); properties.put("Mobile", 5000); // Print Properties details System.out.println("Properties: " + properties.toString()); // Getting the hashCode value System.out.println("HashCode: " + properties.hashCode()); } } Output: Properties: {Book=500, Mobile=5000, Pen=10, Clothes=400} HashCode: 548388082 Program 2: Java // Java program to demonstrate // hashCode() method. import java.util.*; public class GFG { // Main method public static void main(String[] args) { // Create a properties and add some values Properties properties = new Properties(); properties.put(1, "100RS"); properties.put(2, "500RS"); properties.put(3, "1000RS"); // Print Properties details System.out.println("Current Properties: " + properties.toString()); // Getting the hashCode value System.out.println("HashCode: " + properties.hashCode()); } } Output: Current Properties: {3=1000RS, 2=500RS, 1=100RS} HashCode: 1545792714 References: https://docs.oracle.com/javase/9/docs/api/java/util/Properties.html#hashCode-- Comment More infoAdvertise with us Next Article Properties hashCode() method in Java with Examples K Kirti_Mangal Follow Improve Article Tags : Java Java - util package Java-Functions Java-Properties Practice Tags : Java Similar Reads 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 SortedSet hashCode() method in Java with Examples The hashCode() method of SortedSet in Java is used to get the hashCode value for this instance of the SortedSet. It returns an integer value which is the hashCode value for this instance of the SortedSet. Syntax: public int hashCode() Parameters: This function has no parameters. Returns: The method 2 min read Short hashCode() method in Java with Examples The hashCode() method of Short class is a built in method in Java which is used to return the hash code of the ShortObject. Note: The hashCode() returns the same value as intValue(). Syntax ShortObject.hashCode() Return Value: It return an int value which represents the hashcode of the specified Sho 2 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 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 Like