Aargs: "Generating Random Integers in The Range 1..10."
Aargs: "Generating Random Integers in The Range 1..10."
import java.util.Random;
int START = 1;
int END = 10;
Random random = new Random();
for (int idx = 1; idx <= 10; ++idx){
showRandomInteger(START, END, random);
}
log("Done.");
}
screenshot
10)
public class MainClass
{
public static void main(String[] args)
{
Random random = new Random();
//Generating random integers using Random class
for(int i = 0; i < 5; i++)
{
System.out.println("Random Integers : "+random.nextInt());
}
System.out.println("-----------------------------");
//Generating random doubles using Random class
for(int i = 0; i < 5; i++)
{
System.out.println("Random Doubles : "+random.nextDouble());
}
System.out.println("-----------------------------");
//Generating random booleans using Random class
for(int i = 0; i < 5; i++)
{
System.out.println("Random booleans : "+random.nextBoolean());
}
}
}
Screenshot