Java BigInteger(int numBits, Random rnd) Constructor

Syntax

BigInteger(int numBits, Random rnd) constructor from BigInteger has the following syntax.

public BigInteger(int numBits,   Random rnd)

Example

In the following code shows how to use BigInteger.BigInteger(int numBits, Random rnd) constructor.


import java.math.BigInteger;
import java.util.Random;
//from  ww w  .  j av a 2 s  .  c  om
public class Main {
  public static void main(String[] args) throws Exception {
    int bitLength = 512; // 512 bits
    Random rnd = new Random();
    System.out.println("BitLength : " + bitLength);
    BigInteger mod = new BigInteger(bitLength,  rnd);

  }
}

The code above generates the following result.





















Home »
  Java Tutorial »
    java.math »




BigDecimal
BigInteger