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:

Guide to Guava Table
The StackOverflowError in Java
Java Program to Create a Random Graph Using Random Edge Generation
Guide to Apache Commons CircularFifoQueue
Send an email using the SMTP protocol
Java Program to Implement Solovay Strassen Primality Test Algorithm
Class Loaders in Java
Guide to Guava Multimap
Spring REST API + OAuth2 + Angular (using the Spring Security OAuth legacy stack)
Java Program to Generate Random Partition out of a Given Set of Numbers or Characters
Login For a Spring Web App – Error Handling and Localization
Check If a File or Directory Exists in Java
Spring Cloud AWS – RDS
Java Program to Construct K-D Tree for 2 Dimensional Data
Giới thiệu thư viện Apache Commons Chain
How to Iterate Over a Stream With Indices
How to Convert List to Map in Java
Removing all Nulls from a List in Java
Java Program to Generate Random Numbers Using Middle Square Method
Java Program to Implement Sieve Of Atkin
Spring Data Reactive Repositories with MongoDB
Java Program to Create a Random Linear Extension for a DAG
Java Program to Find the Minimum Element of a Rotated Sorted Array using Binary Search approach
Java Program to Implement Levenshtein Distance Computing Algorithm
Java Program to Compute the Volume of a Tetrahedron Using Determinants
Java Program to Implement the Hill Cypher
Spring MVC and the @ModelAttribute Annotation
Guide to the Java ArrayList
Functional Interface trong Java 8
Jackson Ignore Properties on Marshalling
Migrating from JUnit 4 to JUnit 5
Lập trình đa luồng với Callable và Future trong Java