When doing business calculations in Java, especially for currencies, you would preferably use the java.math.BigDecimal class to avoid the problems related to floating-point arithmetic, which you might experience if you’re using one of the two primitive types: float or double (or one of their boxed type counterparts).
Indeed, the BigDecimal class contains a number of methods that can meet most of the requirements of common business calculations.
However, I would like to draw your attention to four common pitfalls of the BigDecimal class. They can be avoided when you use the regular BigDecimal API and when you use a new customized class that extends BigDecimal.
to read full – click here https://blogs.oracle.com/javamagazine/four-common-pitfalls-of-the-bigdecimal-class-and-how-to-avoid-them
for more java related articles , you can also visit duxsm.com/java