logo

Divide two BigDecimal values

Java Code Examples for java.math.BigDecimal.divide()

This method to divide two BigDecimal values.

package simplesolution.dev;

import java.math.BigDecimal;

public class BigDecimalDivideExamples {

    public static void main(String... args) {
        BigDecimal bigDecimal1 = new BigDecimal("40.04");
        BigDecimal bigDecimal2 = new BigDecimal("10.01");

        BigDecimal result = bigDecimal1.divide(bigDecimal2);

        System.out.println(bigDecimal1);
        System.out.println(bigDecimal2);
        System.out.println(result);
    }
}

Happy Coding 😊

Tags: