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:

Jackson – Unmarshall to Collection/Array
Java Program to Find MST (Minimum Spanning Tree) using Prim’s Algorithm
REST Web service: HTTP Status Code và xử lý ngoại lệ RESTful web service với Jersey 2.x
Java Program to Implement LinkedTransferQueue API
OAuth 2.0 Resource Server With Spring Security 5
Guide to Escaping Characters in Java RegExps
Java Program to Implement Rope
Checking for Empty or Blank Strings in Java
Java Program to Perform Preorder Recursive Traversal of a Given Binary Tree
Hướng dẫn sử dụng Java Reflection
Hamcrest Collections Cookbook
Introduction to Spring Cloud Rest Client with Netflix Ribbon
Java Program to Compute the Volume of a Tetrahedron Using Determinants
Dockerizing a Spring Boot Application
Spring Boot - Application Properties
Java Program to Find the Edge Connectivity of a Graph
Guide to the Java Queue Interface
Java Program to Check Cycle in a Graph using Graph traversal
Java Program to Perform Finite State Automaton based Search
Java Program to Implement Karatsuba Multiplication Algorithm
Truyền giá trị và tham chiếu trong java
Spring Cloud – Securing Services
Show Hibernate/JPA SQL Statements from Spring Boot
Removing all Nulls from a List in Java
Life Cycle of a Thread in Java
Jackson vs Gson
Java Program to Implement Sorted Circular Doubly Linked List
Java Program to Implement Disjoint Sets
Returning Image/Media Data with Spring MVC
Using Spring @ResponseStatus to Set HTTP Status Code
Function trong Java 8
OAuth2 Remember Me with Refresh Token