Java Data Type Tutorial - Java BigInteger.toString()








Syntax

BigInteger.toString() has the following syntax.

public String toString()

Example

In the following code shows how to use BigInteger.toString() method.

//from w w w.j a v  a2 s . c  o  m
import java.math.BigInteger;

public class Main {

  public static void main(String[] args) {

    BigInteger bi1 = new BigInteger("1234");
    BigInteger bi2 = new BigInteger("-1234");

    System.out.println(bi1.toString());
    System.out.println(bi2.toString());
  }
}

The code above generates the following result.