سؤال

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