Java BigInteger and() Method

20 Mar 2025 | 2 min read

The and() method of Java BigInteger class returns a BigInteger whose value is (this & val).

Syntax:

Parameter:

val- A value to be AND'ed with this BigInteger.

Returns:

This method returns a BigInteger object of value, this &val .

Note:This method returns a negative BigInteger if and only if this and val are both negative.

Example 1

Output:

 Result is 1 

Example 2

Output:

 Result is -7 

Example 3

Output:

 esult is 5 
 
Next TopicJava BigInteger