- Data Structure
- Networking
- RDBMS
- Operating System
- Java
- MS Excel
- iOS
- HTML
- CSS
- Android
- Python
- C Programming
- C++
- C#
- MongoDB
- MySQL
- Javascript
- PHP
- Physics
- Chemistry
- Biology
- Mathematics
- English
- Economics
- Psychology
- Social Studies
- Fashion Studies
- Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Java Program to perform AND operation on BigInteger
The java.math.BigInteger.and(BigInteger val) returns a BigInteger whose value is (this & val). This method returns a negative BigInteger if and only if this and val are both negative. Here, “val” is the value to be AND'ed with this BigInteger.
First, create BigInteger objects −
BigInteger one, two, three; one = new BigInteger("12"); two = new BigInteger("6");
Perform AND operation on first and second object −
three = one.and(two);
The following is an example −
Example
import java.math.*; public class Demo { public static void main(String[] args) { BigInteger one, two, three; one = new BigInteger("12"); two = new BigInteger("6"); three = one.and(two); System.out.println("Result: " +three); } }
Output
Result: 4
Advertisements