Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- 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 create random BigInteger within a given range
Create a Random class object −
Random random = new Random();
Now let us create a random BigInteger within the range set below −
BigInteger i = new BigInteger(1024, random);
Example
import java.math.BigInteger;
import java.util.Random;
public class Demo {
public static void main(String[] args) {
Random random = new Random();
BigInteger i = new BigInteger(1024, random);
System.out.println("Random BigInteger = "+i);
}
}
Output
Random BigInteger = 172988250696765715389833755481951104504569480256142363412177847577736195982554760981595486734850686498607899498518922990162874103419942352546847073039976287403845518172884710426458735414702299598858093908453406020426533304237452347610248118892069951238970445771615614781904759399589093691142208659284351662649
Advertisements