In this post, I will explain about a Java program to generate random numbers with an example and program output.
This is a very basic program in Java programming language. If you are Java beginners or want to start learning Java programming language, then this program will help you to understand the basic Java programming.
Before executing this program I assume you have configured Java in your computer. Copy the below program and create a file “GenerateRandomNumber.java” and execute it to generate random numbers.
public static void main(String args)
Scanner SC = new Scanner(System.in);
Random rand = new Random();
System.out.print("Please enter maximum range: ");
for(int loop=1; loop<=10; loop++)
Please enter maximum range: 200
If you like FreeWebMentor and you would like to contribute, you can write an article and mail your article to [email protected] Your article will appear on the FreeWebMentor main page and help other developers.
Article Tags: generate random number in java, Java program, Java programming, Java programs, Java programs with examples, Java programs with output, random number in java, random number program in java