ShortBuffer hashCode() Method in Java with Examples Last Updated : 17 Jun, 2019 Comments Improve Suggest changes Like Article Like Report The hashCode() method of java.nio.ShortBuffer is used to return the hash code for a particular buffer. The hash code of a short buffer depends only upon its remaining elements; that is, upon the elements from position() up to, and including, the element at limit() - 1. Because buffer hash codes are content-dependent, it is inadvisable to use buffers as keys in hash maps or similar data structures unless it is known that their contents will not change. Syntax: public int hashCode() Parameters: The method does not take any parameters. Return Value: The method returns the current hash code of the buffer. Below programs illustrate the use of hashCode() method: Program 1: Java // Java program to demonstrate // compareTo() method import java.nio.*; import java.util.*; public class GFG { public static void main(String[] args) { // create short object and assign value to it short shortNum1 = 150; Short ShortObj1 = new Short(shortNum1); // returns hashcode int hcode = ShortObj1.hashCode(); System.out.println("Hashcode for this Short ShortObj1 = " + hcode); } } Output: Hashcode for this Short ShortObj1 = 150 Program 2: Java // Java program to demonstrate // compareTo() method import java.nio.*; import java.util.*; public class GFG { public static void main(String[] args) { // create short object and assign value to it short shortNum1 = 6010; Short ShortObj1 = new Short(shortNum1); // returns hashcode int hcode = ShortObj1.hashCode(); System.out.println("Hashcode for this Short ShortObj1 = " + hcode); } } Output: Hashcode for this Short ShortObj1 = 6010 Reference: https://docs.oracle.com/javase/9/docs/api/java/nio/ShortBuffer.html#hashCode-- Comment More infoAdvertise with us Next Article ShortBuffer hashCode() Method in Java with Examples I IshwarGupta Follow Improve Article Tags : Misc Java Java-Functions Java-ShortBuffer Java-NIO package +1 More Practice Tags : JavaMisc Similar Reads 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 SortedMap hashCode() method in Java with Examples The hashCode() method of SortedMap interface in Java is used to generate a hashCode for the given map containing key and values. Syntax: int hashCode() Parameters: This method has no argument. Returns: This method returns the hashCode value for the given map. Note: The hashCode() method in SortedMap 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 StringWriter hashCode() method in Java with Examples The hashCode() method of StringWriter Class in Java is used to get the HashCode value of this StringWriter instance. This method does not accepts any parameter and returns the required int value. Syntax: public int hashCode() Parameters: This method accepts does not accepts any parameter. Return Val 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