Declare BigDecimal value

The following example demonstrates adding of two BigDecimal number.

We are declaring the BigDecimal value first and then adding two BigDecimal values.

package xtrack.web;

import java.math.BigDecimal;

public class TesC {
public static void main(String args[]){
 BigDecimal test = new BigDecimal(5);
  test=test.add(new BigDecimal(45));
  System.out.println(test);
}
}

Prints :50

Comments