Java Data Type Tutorial - Java BigDecimal.toString()








Syntax

BigDecimal.toString() has the following syntax.

public String toString()

Example

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

import java.math.BigDecimal;
import java.math.MathContext;
//www  .  j  ava 2  s . com
public class Main {

  public static void main(String[] args) {
    MathContext mc = new MathContext(3); // 3 precision

    BigDecimal bg = new BigDecimal("1234E4", mc);

    System.out.println(bg.toString());
  }
}

The code above generates the following result.