Parse decimal string to create BigInteger in Java

To parse the decimal string to create BigInteger, just set the decimal string in the BigInteger.

Here is our BigInteger.

BigInteger one;
String decStr = "687879";
one = new BigInteger(decStr);

Let us see another example −


 Live Demo

import java.math.*;
public class Demo {
   public static void main(String[] args) {
      BigInteger one, two;
      String decStr = "4373427";
      one = new BigInteger("250");
      two = new BigInteger(decStr);
      System.out.println("Result (BigInteger) : " +one);
      System.out.println("Result (Parsing Decimal String) : " +two);


Result (BigInteger) : 250
Result (Parsing Decimal String) : 4373427
karthikeya Boyini
karthikeya Boyini

I love programming (: That's all I know