BigDecimal dividend = new BigDecimal("10.5"); BigDecimal divisor = new BigDecimal("3"); BigDecimal remainder = dividend.remainder(divisor); System.out.println("The remainder of " + dividend + " divided by " + divisor + " is " + remainder);
import java.math.BigDecimal; public class Main { public static void main(String[] args) { BigDecimal big1 = new BigDecimal("1000000000000000000000"); BigDecimal big2 = new BigDecimal("100000000000000000000"); BigDecimal remainder = big1.remainder(big2); System.out.println(remainder); } }This example demonstrates how to find the remainder of dividing a very large BigDecimal by another. The remainder() method is used to calculate the remainder of dividing 1000000000000000000000 by 100000000000000000000, which is 0. The result is stored in the BigDecimal object remainder, which is then printed to the console. The BigDecimal class is part of the standard Java library, specifically in the java.math package.