Java – How to Negate a BigDecimal in Java ?

Problem Statement

You need to negate the value of the BigDecimal datatype in your java program.


Use the negate method defined in the BigDecimal class as shown below.

import java.math.BigDecimal;

public class Main {

    public static void main(String[] args) {

        System.out.println(" Java Tutorials");

        BigDecimal input1 = new BigDecimal(10102);
        BigDecimal output = input1.negate();


The output of the above program is Java Tutorials


%d bloggers like this: