File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
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
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "[Ask] java.util.Random Algorithm? "" Watch "[Ask] java.util.Random Algorithm? "" New topic

[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..

(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é

Joined: Nov 24, 2005
Posts: 14688

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

[My Blog]
All roads lead to JavaRanch
Henry Wong

Joined: Sep 28, 2004
Posts: 20535

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


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

Joined: Oct 13, 2005
Posts: 46397
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:
subject: [Ask] java.util.Random Algorithm? "
It's not a secret anymore!