Beginner in java, need to write a random number generator.

ChristopherThe Great's Avatar, Join Date: Mar 2009
Newbie Member
Hello everyone, I am new to java and am having quite a bit of trouble with it. I have to write a random number generator with numbers between 0-50. I also have to put something in with a determineLowest to return the lowest number. I am using Eclpise to write and test the program. Can anyone offer me some pointers or places to start? I have browsed through my book, and it did not help me at all. Thanks.
xpi0t0s's Avatar, Join Date: Aug 2004
Did you try Googling "java random numbers"?
Ascendancy's Avatar, Join Date: Feb 2007
Go4Expert Member
One of the first results from Google. Enjoy:

import java.util.Random;

/** Generate 10 random integers in the range 0..99. */
public final class RandomInteger {
  public static final void main(String... aArgs){
    log("Generating 10 random integers in range 0..99.");
    //note a single Random object is reused here
    Random randomGenerator = new Random();
    for (int idx = 1; idx <= 10; ++idx){
      int randomInt = randomGenerator.nextInt(100);
      log("Generated : " + randomInt);
  private static void log(String aMessage){