- Trending Categories
- 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
Multiply one BigInteger to another BigInteger in Java
BigInteger class is used for big integer calculations which are outside the limit of the primitive data types. It provides operations for modular arithmetic, GCD calculation, primality testing, prime generation, bit manipulation, and a few other miscellaneous operations.
To multiply one BigInteger to another, use the BigInteger multiply() method.
First, let us create some objects −
BigInteger one, two, three; one = new BigInteger("2"); two = new BigInteger("8");
Multiply the above and assign it to the third object −
three = one.multiply(two);
The following is an example −
Example
import java.math.*; public class BigIntegerDemo { public static void main(String[] args) { BigInteger one, two, three; one = new BigInteger("2"); two = new BigInteger("8"); three = one.multiply(two); String res = one + " * " + two + " = " +three; System.out.println("Multiplication: " +res); } }
Output
Multiplication: 2 * 8 = 16
Advertisements