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 Selenium with JUnit / TestNG
Java Program to Implement Sorted Singly Linked List
Configure a Spring Boot Web Application
New Features in Java 8
Returning Custom Status Codes from Spring Controllers
Test a REST API with Java
Java Program to Find a Good Feedback Edge Set in a Graph
Jackson JSON Views
Guide to BufferedReader
Java Program to Check whether Directed Graph is Connected using DFS
Spring Boot - Quick Start
Instance Profile Credentials using Spring Cloud
File Upload with Spring MVC
Spring Cloud – Tracing Services with Zipkin
Hướng dẫn Java Design Pattern – Visitor
Working With Maps Using Streams
Java Program to Implement Sorted Vector
Java Program to Implement HashTable API
Java Program to Implement Trie
Java Program to Implement Borwein Algorithm
Spring Boot - Rest Controller Unit Test
Java Program to Implement Circular Singly Linked List
Using a Mutex Object in Java
Java 9 Stream API Improvements
Lớp lồng nhau trong java (Java inner class)
Java Program to Implement Graph Coloring Algorithm
Weak References in Java
Java Program to Implement Patricia Trie
JUnit5 Programmatic Extension Registration with @RegisterExtension
Java Program to Implement Disjoint Sets
Java Program to Implement Self organizing List
Hướng dẫn Java Design Pattern – Dependency Injection