Java convert BigInteger to String

Tags: BigInteger BigInteger toString String

In this Java core tutorial we learn how to use the java.math.BigInteger.toString() method to convert a BigInteger value to a String value.

How to convert BigInteger to String

To convert a BigInteger object to a String we can use the method java.math.BigInteger.toString() which returns the decimal String representation of a BigInteger value.

ConvertBigIntegerToStringExample.java

import java.math.BigInteger;

public class ConvertBigIntegerToStringExample {
    public static void main(String... args) {
        BigInteger value = new BigInteger("1234567890987654321");

        String stringValue = value.toString();

        System.out.println("BigInteger value: " + value);
        System.out.println("String value: " + stringValue);
    }
}
The output is:
BigInteger value: 1234567890987654321
String value: 1234567890987654321

Happy Coding 😊