This is the question i got and how can i limit it to a range ? My code is below. Thanks
Question : Write a method call genRandom() to generate 5 Random integer numbers between 1 to 100 and print them on to the screen. Invoke genRandom() inside the main().
import java.util.Random;
class RandomNumbers{
public static void main(String [] args){
Random randomNum = new Random();
for(int i = 0; i<5; i++){
System.out.println("Random number is : " + randomNum.nextInt(5));
}
}
}