BigInteger not() in Java

not(): This method is available in java. math.BigInteger class of Java.

Syntax:

BigInteger java.math.BigInteger.not()

This method returns a BigInteger whose value is (~this). (This method returns a negative  value if and only if this BigInteger is non-negative.)

Returns: ~this

For Example:

BigInteger bigInteger = new BigInteger("1234")

bigInteger.not() = > It returns -1235.

Approach

Java

import java.math.BigInteger;

public class BigIntegernot {
    public static void main(String[] args) {

        BigInteger bigInteger = new BigInteger("1234");
        System.out.println(bigInteger.not());
    }
}

Output:

-1235

No comments:

Post a Comment