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:
List Interface trong Java
Quick Guide to @RestClientTest in Spring Boot
Java Program to Find the Shortest Path Between Two Vertices Using Dijkstra’s Algorithm
Hướng dẫn sử dụng lớp Console trong java
Jackson – Decide What Fields Get Serialized/Deserialized
Spring Boot - Tracing Micro Service Logs
Java Program to Print the Kind of Rotation the AVL Tree is Undergoing
Binary Numbers in Java
A Guide to the Java ExecutorService
Class Loaders in Java
Chuyển đổi giữa các kiểu dữ liệu trong Java
Get the workstation name or IP
A Guide To UDP In Java
Constructor Dependency Injection in Spring
Sorting Query Results with Spring Data
So sánh ArrayList và LinkedList trong Java
Working with Network Interfaces in Java
Java Program to Implement SimpeBindings API
How to Remove the Last Character of a String?
@Before vs @BeforeClass vs @BeforeEach vs @BeforeAll
Java Program to Implement Meldable Heap
Giới thiệu về Stream API trong Java 8
Java Program to Implement Word Wrap Problem
Java 8 and Infinite Streams
Java Program to Implement Warshall Algorithm
Java Program to Implement Ternary Heap
Map Interface trong java
SOAP Web service: Authentication trong JAX-WS
Java Program to Implement Range Tree
Java Program to Implement Patricia Trie
Java Program to Create a Random Graph Using Random Edge Generation
Logging in Spring Boot