The hashCode() method of Double class is a built-in method use to return the hashcode value of this Double object.
Syntax:
DoubleObject.hashCode()
Parameters: It takes no parameters.
Return Type: It returns an int value. The value returned is (int)(v^(v>>>32)) where v is a long variable equal to Double.doubleToLongBits(this.doubleValue()).
Below is the implementation of hashCode() method:
Example 1:
class GFG {
public static void main(String[] args)
{
double d = 118.698 ;
Double value = new Double(d);
int output = value.hashCode();
System.out.println( "Hashcode Value of "
+ value + " : "
+ output);
}
}
|
Output:
Hashcode Value of 118.698 : 1215072837
Example 2:
class GFG {
public static void main(String[] args)
{
int i = - 30 ;
Double value = new Double(i);
int output = value.hashCode();
System.out.println( "Hashcode Value of "
+ value + " : "
+ output);
}
}
|
Output:
Hashcode Value of -30.0 : -1069678592
Whether you're preparing for your first job interview or aiming to upskill in this ever-evolving tech landscape,
GeeksforGeeks Courses are your key to success. We provide top-quality content at affordable prices, all geared towards accelerating your growth in a time-bound manner. Join the millions we've already empowered, and we're here to do the same for you. Don't miss out -
check it out now!
Last Updated :
12 Oct, 2018
Like Article
Save Article