ShortBuffer hashCode() Method in Java with Examples
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.
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:
Hashcode for this Short ShortObj1 = 150
Hashcode for this Short ShortObj1 = 6010