In this tutorial, we will see how to convert String to BigInteger in java.
It is simple to convert String to BigInteger in java.We can simply use BigInteger’s constructor to convert String to BigInteger.
1 2 3 |
BigInteger(String val) |
Above constructor convert String representation of BigInteger to BigInteger
Let’s see this with the help of example:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 |
package org.arpit.java2blog; 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); } } |
When you run above program, you will get below output:
Converted String to BigInteger: 45
that’s all about converting String to BigInteger.
Was this post helpful?
Let us know if this post was helpful. Feedbacks are monitored on daily basis. Please do provide feedback as that\'s the only way to improve.