This is java program to generate the random numbers, in the range given by the user. Range could be any numbers of size integer supported by Java.
Here is the source code of the Java Program to Generate Randomized Sequence of Given Range of Numbers. The Java program is successfully compiled and run on a Windows system. The program output is also shown below.
//This is the sample program to generate a randomized sequence of numbers
import java.util.Random;
import java.util.Scanner;
public class Randomized_Sequence_Random_Numbers
{
public static void main(String args[])
{
Random rand = new Random();
Scanner sc = new Scanner(System.in);
System.out.println("Enter the starting and ending of the sequence: ");
int start = sc.nextInt();
int end = sc.nextInt();
for(int i=0; i<15; i++)
{
System.out.print(rand.nextInt(end-start+1)+start + ", ");
}
System.out.print("...");
sc.close();
}
}
Output:
$ javac Randomizied_Sequence_Random_Numbers.java $ java Randomizied_Sequence_Random_Numbers Enter the starting and ending of the sequence: 100 1000 490, 574, 179, 447, 723, 891, 589, 312, 667, 653, 375, 667, 990, 573, 399, ...
Related posts:
Java Program to Implement Rolling Hash
A Guide to Apache Commons Collections CollectionUtils
Java Program to Implement Self organizing List
Java Program to Implement LinkedTransferQueue API
Hướng dẫn sử dụng luồng vào ra ký tự trong Java
Serve Static Resources with Spring
A Guide to Queries in Spring Data MongoDB
Java Program to Check Whether a Directed Graph Contains a Eulerian Cycle
Supplier trong Java 8
Hướng dẫn tạo và sử dụng ThreadPool trong Java
Java Program to Find ith Largest Number from a Given List Using Order-Statistic Algorithm
Java Program to subtract two large numbers using Linked Lists
Java Program to Generate Random Numbers Using Probability Distribution Function
What is a POJO Class?
Quick Guide to Spring Controllers
Lập trình đa luồng với CompletableFuture trong Java 8
Using the Map.Entry Java Class
Add Multiple Items to an Java ArrayList
ETags for REST with Spring
JUnit5 Programmatic Extension Registration with @RegisterExtension
Java Timer
Merging Streams in Java
Spring @RequestParam Annotation
Stack Memory and Heap Space in Java
Migrating from JUnit 4 to JUnit 5
Java Web Services – JAX-WS – SOAP
Hướng dẫn Java Design Pattern – Service Locator
Finding the Differences Between Two Lists in Java
Java Program to Check Whether an Input Binary Tree is the Sub Tree of the Binary Tree
Java Program to Find Nearest Neighbor for Dynamic Data Set
Java Program to Implement Nth Root Algorithm
Giới thiệu java.io.tmpdir