Java Data Type Tutorial - Java BigDecimal(String val) Constructor








Syntax

BigDecimal(String val) constructor from BigDecimal has the following syntax.

public BigDecimal(String val)

Example

In the following code shows how to use BigDecimal.BigDecimal(String val) constructor.

// w w  w.  j av  a 2  s. c om
import java.math.BigDecimal;

public class Main {

  public static void main(String[] args) {
    BigDecimal bg1 = new BigDecimal("123.456789");
    System.out.println(bg1);

  }
}

The code above generates the following result.