Double hashCode() method in Java with examples
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:
// Java code to demonstrate // Double hashCode() Method class GFG { public static void main(String[] args) { double d = 118.698; // creating Double object. Double value = new Double(d); // hashCode() method Double class int output = value.hashCode(); // printing the output System.out.println("Hashcode Value of " + value + " : " + output); } } |
chevron_right
filter_none
Output:
Hashcode Value of 118.698 : 1215072837
Example 2:
// Java code to demonstrate // Double hashCode() Method class GFG { public static void main(String[] args) { int i = -30; // creating Double object. Double value = new Double(i); // hashCode() method Double class int output = value.hashCode(); // printing the output System.out.println("Hashcode Value of " + value + " : " + output); } } |
chevron_right
filter_none
Output:
Hashcode Value of -30.0 : -1069678592
Recommended Posts:
- Java Guava | Doubles.indexOf(double[] array, double[] target) method with Examples
- Java Guava | Doubles.indexOf(double[] array, double target) method with Examples
- Set hashCode() method in Java with Examples
- Map hashCode() Method in Java with Examples
- OffsetDateTime hashCode() method in Java with examples
- OptionalInt hashCode() method in Java with examples
- SimpleDateFormat hashCode() Method in Java with Examples
- ChronoPeriod hashCode() method in Java with Examples
- Locale hashCode() Method in Java with Examples
- Short hashCode() method in Java with Examples
- Calendar hashCode() Method in Java with Examples
- ZoneId hashCode() method in Java with Examples
- List hashCode() Method in Java with Examples
- Path hashCode() method in Java with Examples
- AbstractSet hashCode() Method in Java with Examples
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.



