This week's book giveaway is in the Java 8 forum.
We're giving away four copies of Java 8 in Action and have Raoul-Gabriel Urma, Mario Fusco, and Alan Mycroft 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 Java 8 in Action this week in the Java 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: 14687
    
  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: 18136
    
  39


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: 36578
    
  16
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? "
 
Similar Threads
random number generating
Question on java.util.Random
Math.random
random number question
Random insert and delete into an arraylist