valueof « bigdecimal « Java Data Type Q&A





1. Error with BigDecimal calculation regarding User Input     stackoverflow.com

I have this idea for my assignment where I wanted a cash register system to calculate the total for an item when the user enters it's cost price and quantity of ...

2. BigDecimal - to use new or valueOf    stackoverflow.com

I came across two ways of getting BigDecimal object out of a double d.

1. new BigDecimal(d)
2. BigDecimal.valueOf(d)
Which would be a better approach? Would valueOf create a new object? In general (not just BigDecimal), ...