Lets say ItemImpl takes in "int ItemId, String name, BigDecimal price"
How do I put a BigDecimal number in the input of this?
Item item = new ItemImpl(5, "Hockey Stick", BigDecimal(1.5));
Also what's the point of BigDecimal?
Lets say ItemImpl takes in "int ItemId, String name, BigDecimal price"
How do I put a BigDecimal number in the input of this?
Item item = new ItemImpl(5, "Hockey Stick", BigDecimal(1.5));
Also what's the point of BigDecimal?
Item item = new ItemImpl(5, "Hockey Stick", new BigDecimal("1.5"));
Best practice is to use a String due to precision issues
And this link I think answers pretty much everything you might want to know: http://www.opentaps.org/docs/index.php/How_to_Use_Java_BigDecimal:_A_Tutorial
The point of BigDecimal
is that it offers better precision than double
and it also solves round-off errors.