Java Math BigInteger.nextProbablePrime() 方法


Java Math BigInteger.nextProbablePrime() 方法

package com.codingdict;



import java.math.*;



public class BigIntegerDemo {



   public static void main(String[] args) {



      // create 2 BigInteger objects

      BigInteger bi1, bi2;



      bi1 = new BigInteger("20");



      // assign nextProbablePrime value of bi1 to bi2

      bi2 = bi1.nextProbablePrime();



      String str = "Next probable prime after " + bi1 +" is " +bi2;



      // print bi2 value

      System.out.println( str );

   }

}