Java Program to Generate Randomized Sequence of Given Range of Numbers

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:

How to Iterate Over a Stream With Indices
Java Program to Check whether Graph is Biconnected
Creating a Custom Starter with Spring Boot
Count Occurrences of a Char in a String
OAuth2 for a Spring REST API – Handle the Refresh Token in Angular
Configure a Spring Boot Web Application
Java Program to Implement the Checksum Method for Small String Messages and Detect
Java Program to Implement Graph Structured Stack
Java Program to Implement Naor-Reingold Pseudo Random Function
Giới thiệu về Stream API trong Java 8
New Features in Java 8
Java Program to Delete a Particular Node in a Tree Without Using Recursion
Testing an OAuth Secured API with Spring MVC
Java Program to Implement Find all Back Edges in a Graph
Hướng dẫn Java Design Pattern – Dependency Injection
Java Program to Implement Double Ended Queue
Java Program to Implement Uniform-Cost Search
JWT – Token-based Authentication trong Jersey 2.x
Spring Data MongoDB – Indexes, Annotations and Converters
Tạo số và chuỗi ngẫu nhiên trong Java
Java Program to Implement RenderingHints API
Basic Authentication with the RestTemplate
A Guide to WatchService in Java NIO2
Giới thiệu thư viện Apache Commons Chain
Lập trình đa luồng trong Java (Java Multi-threading)
Java Program to Implement Sorted Doubly Linked List
Java Program to Implement Pagoda
Consumer trong Java 8
How to Replace Many if Statements in Java
Java Program to Implement Find all Forward Edges in a Graph
Java Program to Implement Selection Sort
Java – Convert File to InputStream