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 Head First Android this week in the Android 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

Genratting Random number useing java.util.Random

Chiranjeevi Kanthraj
Ranch Hand

Joined: Feb 18, 2008
Posts: 290

Hi i need a integer which must be positive

but this is giving -ve also

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

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
I agree. Here's the link:
subject: Genratting Random number useing java.util.Random
It's not a secret anymore!