You would want to use equals()
since they are objects, and utilize the built in ZERO
instance:
if (selectPrice.equals(BigDecimal.ZERO))
Note that .equals()
takes scale into account, so unless selectPrice is the same scale (0) as .ZERO
then this will return false.
To take scale out of the equation as it were:
if (selectPrice.compareTo(BigDecimal.ZERO) == 0)
I should note that for certain mathematical situations, 0.00 != 0
, which is why I imagine .equals()
takes the scale into account. 0.00
gives precision to the hundredths place, whereas 0
is not that precise. Depending on the situation you may want to stick with .equals()
.