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 Kill a Java Thread
Java Program to Implement Regular Falsi Algorithm
Java Program to Implement Ford–Fulkerson Algorithm
Introduction to Spring Cloud OpenFeign
Spring @RequestParam Annotation
Using a Custom Spring MVC’s Handler Interceptor to Manage Sessions
Spring’s RequestBody and ResponseBody Annotations
Testing an OAuth Secured API with Spring MVC
ETL with Spring Cloud Data Flow
@Lookup Annotation in Spring
Introduction to Liquibase Rollback
Java Program to Compute the Volume of a Tetrahedron Using Determinants
Java Program to Implement Variable length array
Test a REST API with Java
Returning Custom Status Codes from Spring Controllers
Java Program to Implement the One Time Pad Algorithm
Hướng dẫn kết nối cơ sở dữ liệu với Java JDBC
Java Program to Perform integer Partition for a Specific Case
Giới thiệu Google Guice – Dependency injection (DI) framework
Tạo chương trình Java đầu tiên sử dụng Eclipse
A Guide to Java SynchronousQueue
Chuyển đổi từ HashMap sang ArrayList
Hướng dẫn Java Design Pattern – Abstract Factory
Java Program to Implement Hamiltonian Cycle Algorithm
Automatic Property Expansion with Spring Boot
Java Program to Implement Fibonacci Heap
What is a POJO Class?
Java Program to Implement the MD5 Algorithm
Intro to Inversion of Control and Dependency Injection with Spring
Java Program to Implement Randomized Binary Search Tree
Removing all Nulls from a List in Java
Converting Between Byte Arrays and Hexadecimal Strings in Java