java字符串转换为biginteger
时间:2020-02-23 14:35:15 来源:igfitidea点击:
在本教程中,我们将看到如何将字符串转换为Java中的BigInteger。
将字符串转换为Java中的BigInteger很简单。
我们只需使用BigInteger的构造函数将字符串转换为BigInteger。
BigInteger(String val)
上面的构造函数将BIGINTEGER的字符串表示转换为BIGINTEGER让我们在举例的帮助下看到这个:
package org.igi.theitroad;
import java.math.BigInteger;
public class StringToBigIntegerMain {
public static void main(String[] args) {
String str="45";
BigInteger bigIntegerStr=new BigInteger(str);
System.out.println("Converted String to BigInteger: "+bigIntegerStr);
}
}
运行上面的程序时,我们将得到以下输出:
Converted String to BigInteger: 45

