Question

I need method which will generate a big decimal numbers between 0.00 to 1000.00. anyone can help? In google i can find only between 0-1 or something else... but this doesn't help me Thank You!

Était-ce utile?

La solution

new BigDecimal(BigInteger.valueOf(new Random().nextInt(100001)), 2)

Generates an integer uniformly at random between 0 and 10,000 inclusive, and creates a BigDecimal with that value divided by 100.

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top