Facebook Page Twitter Page LinkedIn Page
× Java.lang Package Classes


The java.lang.Double.hashCode() method is used to return a hash code for a double value which is compatible with Double.hashCode().

Syntax

public static int hashCode(double value)

Parameters

value Specify the value to hash.

Return Value

Returns a hash code value for a double value.

Exception

NA.

Example:

In the below example, the java.lang.Double.hashCode() method is used to return a hash code for the given double value.

import java.lang.*;

public class MyClass {
  public static void main(String[] args) {
    
    //creating double values
    double val1 = 10.25;
    double val2 = -10.25;

    //printing hashcode of the double values
    System.out.println("hashCode of the val1 is: " + Double.hashCode(val1)); 
    System.out.println("hashCode of the val2 is: " + Double.hashCode(val2));   
  }
}

The output of the above code will be:

hashCode of the val1 is: 1076133888
hashCode of the val2 is: -1071349760

❮ Java.lang - Double