This week's book giveaway is in the OCAJP 8 forum.
We're giving away four copies of OCA Java SE 8 Programmer I Study Guide and have Edward Finegan & Robert Liguori on-line!
See this thread for details.
The moose likes Beginning Java and the fly likes [Ask] java.util.Random Algorithm? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of OCA Java SE 8 Programmer I Study Guide this week in the OCAJP 8 forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "[Ask] java.util.Random Algorithm? "" Watch "[Ask] java.util.Random Algorithm? "" New topic
Author

[Ask] java.util.Random Algorithm? "

Leonardo Carreira
Ranch Hand

Joined: Apr 07, 2009
Posts: 489

Dear all..

i have any question about the java.util.Random class..

example the mehod : nextInt(int n);
which return an integer with range 0 - n

what the algorithm which implemented in the java.util.Random class?..
i want to write down the flowchart for my case study..

Thank's
(Sorry my english isn't too good)


Sorry, perhaps my english language isn't too good.. Prepare for SCJP 6, Please God help me.. ☼
References : [Java.Boot] [JavaChamp] [JavaPrepare]
Christophe Verré
Sheriff

Joined: Nov 24, 2005
Posts: 14688
    
  16

The API for java.util.Random gives you some details. Did you check it ?


[My Blog]
All roads lead to JavaRanch
Henry Wong
author
Sheriff

Joined: Sep 28, 2004
Posts: 20166
    
  46


A referemce (book which code is based) is provided in the JavaDocs -- see java.util.Random.

Henry


Books: Java Threads, 3rd Edition, Jini in a Nutshell, and Java Gems (contributor)
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 44581
    
  34
Leonardo Carreira wrote:. . . the mehod : nextInt(int n);
which return an integer with range 0 - n
No, an int in the range 0 . . . n-1. You can never get n returned.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: [Ask] java.util.Random Algorithm? "
 
It's not a secret anymore!