Board index Off Topic Board Off Topic Discussion Need help with Java

Need help with Java

Here, anything goes. Talk about anything that you would like to talk about!

Post October 12th, 2006, 7:58 pm

Posts: 2052
Points on hand: 4,906.00 Points
Location: USA

I need help using the Random.nextInt method

here's what I need to do:
-take an integer and assign it to a random number between 0 and 100 inclusive

here's what I have right now, and it's giving me an error

num = Random.nextInt(100);

the compiler keeps saying "non-static method nextInt(int) cannot be reference from a static context"

Can someone help me out?

(And please, if you don't know what I'm talking about or can help me, don't post here, thanks)
Last edited by SMer on October 12th, 2006, 7:58 pm, edited 1 time in total.

Post October 12th, 2006, 8:32 pm

Posts: 2052
Points on hand: 4,906.00 Points
Location: USA


Post October 13th, 2006, 12:49 am
Oscar User avatar
Founding Member
Founding Member

Posts: 14409
Points on hand: 12,059.60 Points
Bank: 187,052.60 Points
Location: California, USA

what he said
Support Us! - Click Here To Donate $5 Monthly!
Paradox wrote:
No need to tell Oscar about the problems. He is magic.

Post October 13th, 2006, 6:41 am

Posts: 5626
Points on hand: 5,993.00 Points
Location: Millbrook, Alabama, USA

Correct. You have to assign the variable differently because you are asking it to assign the number differently, however, if you are unsure of how to explain it you may want to ask because all of a sudden showing up with info that maybe you have not been taught is never a good thing when asked to explain your work. Gosh, I am glad I write in UNIX now .... Java and C+ were spanking me for months!

Post October 13th, 2006, 2:31 pm

Posts: 2052
Points on hand: 4,906.00 Points
Location: USA



Return to Off Topic Discussion