Java Data Type Tutorial - Java BigInteger.toString(int radix)








Syntax

BigInteger.toString(int radix) has the following syntax.

public String toString(int radix)

Example

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

//  w  ww  .  j  a  va  2s.co m

import java.math.BigInteger;

public class Main {

  public static void main(String[] args) {

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

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

The code above generates the following result.