The moose likes Beginning Java and the fly likes array of random numbers Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "array of random numbers" Watch "array of random numbers" New topic

array of random numbers

son dunckley

Joined: Jul 27, 2005
Posts: 17

I have managed to get an array to generate random numbers between 0 and 99. However, I would also like the array to contain negative numbers as well but cannot work out how to do this?

Anyone able to offer advise on this please?

My code is:

ankur rathi
Ranch Hand

Joined: Oct 11, 2004
Posts: 3830
get the number and perform minus operation with 0 for example:

0-10 => -10

hope that is what you are looking.
Jeffrey Spaulding
Ranch Hand

Joined: Jan 15, 2004
Posts: 149
Max Random = 200

your number = -100 + generatedRandomNumber

I agree. Here's the link:
subject: array of random numbers
It's not a secret anymore!