aspose file tools*
The moose likes Beginning Java and the fly likes Genratting Random number useing java.util.Random 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 "Genratting Random number useing java.util.Random" Watch "Genratting Random number useing java.util.Random" New topic
Author

Genratting Random number useing java.util.Random

Chiranjeevi Kanthraj
Ranch Hand

Joined: Feb 18, 2008
Posts: 288

Hi i need a integer which must be positive

but this is giving -ve also


-Chiru
Vikas Kapoor
Ranch Hand

Joined: Aug 16, 2007
Posts: 1374
Hello Chiru,

Did you look at another version of nextInt() method?



The API doc says about this method:

Returns a pseudorandom, uniformly distributed int value between 0 (inclusive) and the specified value (exclusive), drawn from this random number generator's sequence.

[ June 02, 2008: Message edited by: Vishal Pandya ]
marc weber
Sheriff

Joined: Aug 31, 2004
Posts: 11343

Originally posted by Chiru Raj:
...this is giving -ve also

Please Use Real Words. Thanks!


"We're kind of on the level of crossword puzzle writers... And no one ever goes to them and gives them an award." ~Joe Strummer
sscce.org
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: Genratting Random number useing java.util.Random
 
Similar Threads
random number
what are key factors for deciding the technology for the application
Create string in random order.
diff. bet. Math.random() and java.util.random
WA #1.....word association