Skip to Main Content

New to Java

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

generate random number

807600Jun 14 2007 — edited Jun 14 2007
is this right..im trying to generate a random numbre between 1 and 1000.

public void theGame()
{
/* Write a statement that sets instance variable number to a random number
between 1 and 1000 */

Random generator = new Random();

int rn1 = rnd.nextInt(1) + 1000; // number in range 1..1000


} // end method theGame
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Jul 12 2007
Added on Jun 14 2007
2 comments
350 views