Skip to Main Content

New to Java

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Generate a number between 0(inclusive) to 1(inclusive)?

807598Jun 10 2006 — edited Jun 21 2006
Hi all,

I have read the API doc and discovered that the nextDouble() method of the Random class generates a number between 0(inclusive) to 1(exclusive). But I want 1 to be inclusive, so may I ask how this can be done?

Thanks a lot.
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Jul 19 2006
Added on Jun 10 2006
7 comments
190 views