Java BigDecimal hashCode() method

20 Mar 2025 | 2 min read

The hashCode() method of java BigDecimal class is used to obtain the hash code of a BigDecimal Value.

Note: Two BigDecimal objects that are numerically equal but differ in scale (like 2.0 and 2.00) will generally not have the same hash code.

Syntax:

Parameter:

No

Exception:

No

Returns:

It returns hash Code of BigDecimal.

Example 1

Output:

 Returned hash code value is = 3565 

Example 2

Output:

 Returned hash code value is = -3565 

Example 3

Output:

 Returned hash code value is = 511501 

Example 4

Output:

 Returned hash code value is = 5115002 
 
Next TopicJava BigDecimal