문제

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!

도움이 되었습니까?

해결책

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.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top