Question: How to add BigDecimal in Java?
I have two BigDecimal variables. I want to add these two values.
How to add BigDecimal in Java?
I will show you how you can add two BigDecimal?
Suppose you have following two variables:
BigDecimal var1 = BigDecimal(1.02); BigDecimal var2 = BigDecimal(5.08);
There is method of BigDecimal named add() which can be used to add. Here is the example of adding two:
BigDecimal resule = var2.add(var1);
Check tutorial at Add two big numbers.