Tuesday, December 9, 2014

BigDecimal in Java

public void whatever(BigDecimal amount) {

When attempting to call a method like this, you will need at the top of your file...

 
 

import java.math.BigDecimal;

...or...

<%@page import="java.math.BigDecimal"%>

 
 

You will find that you will not be able to just hand in a float for a BigDecimal like so:

whatever(13.42);

 
 

Instead, you'll have to do something like this:

whatever(new BigDecimal(13.42));

No comments:

Post a Comment