Java BigDecimal(int val, MathContext mc) Constructor

Syntax

BigDecimal(int val, MathContext mc) constructor from BigDecimal has the following syntax.

public BigDecimal(int val,   MathContext mc)

Example

In the following code shows how to use BigDecimal.BigDecimal(int val, MathContext mc) constructor.


import java.math.BigDecimal;
import java.math.MathContext;
//from w  w  w. ja  v  a2  s.c om
public class Main {

  public static void main(String[] args) {
    MathContext mc = new MathContext(3);
    BigDecimal bg1 = new BigDecimal(123,mc);
    System.out.println(bg1);

  }
}

The code above generates the following result.





















Home »
  Java Tutorial »
    java.math »




BigDecimal
BigInteger