BigInteger and() in Java

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

Syntax:

BigInteger java.math.BigInteger.and(BigInteger val)

This method takes one argument of type BigInteger as its parameter. It returns a BigInteger whose value is (this & val). (This method returns a negative BigInteger if and only if this and val are both negative.)

Parameters:  One parameter is required for this method.

val: value to be AND'ed with this BigInteger.

Returns: this & val

For Example:

BigInteger bigInteger = new BigInteger("1234")

BigInteger val = new BigInteger("2345")

bigInteger.and(val) = > It returns 0.

Approach

Java

import java.math.BigInteger;

public class BigIntegerand {

    public static void main(String[] args) {

        BigInteger bigInteger = new BigInteger("1234");
        BigInteger val = new BigInteger("2345");
        System.out.println(bigInteger.and(val));
    }
}

Output:

0

No comments:

Post a Comment