wood burning stoves 2.0*
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 Android Security Essentials Live Lessons this week in the Android 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: 18545
    
  40


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: 38062
    
  22
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
Math.random
Question on java.util.Random
Random insert and delete into an arraylist
random number question