In fact, I'd go even further and say that if a class (any class) provides a static valueOf() factory, you should use it in preference to new unless
(a) the documentation tells you otherwise.
(b) there is some overriding reason why you can't.
This is particularly true of BigDecimal. Try out the following:
System.out.println( new BigDecimal(0.1).toPlainString() );
System.out.println( BigDecimal.valueOf(0.1).toPlainString() ); and you'll see what I mean. And for an explanation why it does what it does, look at the documentation for new BigDecimal(double).
Isn't it funny how there's always time and money enough to do it WRONG?
Articles by Winston can be found here