BigInteger(int numBits, Random rnd) constructor from BigInteger has the following syntax.
public BigInteger(int numBits, Random rnd)
In the following code shows how to use BigInteger.BigInteger(int numBits, Random rnd) constructor.
import java.math.BigInteger; import java.util.Random; //from w w w .j av a2s. com 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.