Java BigInteger.probablePrime(int bitLength, Random rnd)

Syntax

BigInteger.probablePrime(int bitLength, Random rnd) has the following syntax.

public static BigInteger probablePrime(int bitLength,    Random rnd)

Example

In the following code shows how to use BigInteger.probablePrime(int bitLength, Random rnd) method.


/* w ww  . j  av  a2  s.  co  m*/

import java.math.BigInteger;
import java.util.Random;

public class Main {

  public static void main(String[] args) {

    int bitLength = 3;

    // create a random object
    Random rnd = new Random();

    BigInteger bi = BigInteger.probablePrime(bitLength, rnd);

    System.out.println(bi);
  }
}

The code above generates the following result.





















Home »
  Java Tutorial »
    java.math »




BigDecimal
BigInteger