Java Short - hashCode() Method
The java.lang.Short.hashCode() method returns a hash code for this Short which is equal to the result of invoking intValue().
Syntax
public int hashCode()
Parameters
No parameter is required.
Return Value
Returns a hash code value for this Short.
Exception
NA.
Example:
In the example below, the java.lang.Short.hashCode() method returns a hash code for the given Short.
import java.lang.*; public class MyClass { public static void main(String[] args) { //creating Short objects Short val1 = 1025; Short val2 = -1025; //printing hashcode of the Short objects System.out.println("hashCode of the val1 is: " + val1.hashCode()); System.out.println("hashCode of the val2 is: " + val2.hashCode()); } }
The output of the above code will be:
hashCode of the val1 is: 1025 hashCode of the val2 is: -1025
❮ Java.lang - Short