wood burning stoves 2.0*
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
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: 289

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
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
 
subject: Genratting Random number useing java.util.Random