Generate random number between range - Java @ Desk

Saturday, May 18, 2013

Generate random number between range














package test;

import java.util.Random;

public class RandomNumberBetweenRange {

 public static void main(String args[]) {
  Random random = new Random();
  int range = 10;
  System.out.println("Random numbers between 0 and " + range + " are : ");
  for (int i = 0; i < 15; i++) {
   System.out.println(random.nextInt(range));
  }
 }
}






No comments:

Post a Comment