-4

How to generate a random double in the interval (0.0,1] in JAVA

It should include the number 1 but not 0.

double initProbability=Math.random(); does not work for my problem

1 Answers1

0

1d - Math.random() does the trick.

Gerhard
  • 280
  • 1
  • 8
  • While this code snippet may solve the question, [including an explanation](http://meta.stackexchange.com/questions/114762/explaining-entirely-code-based-answers) really helps to improve the quality of your post. Remember that you are answering the question for readers in the future, and those people might not know the reasons for your code suggestion. – DimaSan Mar 15 '17 at 11:14