Pergunta

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!

Foi útil?

Solução

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.

Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top