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:
Java Program to Implement Johnson’s Algorithm
Date Time trong Java 8
A Guide to Queries in Spring Data MongoDB
Sort a HashMap in Java
Java Program to Check whether Graph is a Bipartite using 2 Color Algorithm
A Guide To UDP In Java
Java – Reader to InputStream
Guide to the Volatile Keyword in Java
How to Get a Name of a Method Being Executed?
Java Program to Use the Bellman-Ford Algorithm to Find the Shortest Path
Getting the Size of an Iterable in Java
Spring Boot - Apache Kafka
Spring Security Basic Authentication
Spring Data JPA @Modifying Annotation
Java Program to Check if a Point d lies Inside or Outside a Circle Defined by Points a, b, c in a Pl...
Control the Session with Spring Security
Assert an Exception is Thrown in JUnit 4 and 5
Filtering a Stream of Optionals in Java
Java Program to Represent Graph Using Linked List
Java Program to Create the Prufer Code for a Tree
Convert Time to Milliseconds in Java
Java Program to Perform Searching in a 2-Dimension K-D Tree
Java Program to Find SSSP (Single Source Shortest Path) in DAG (Directed Acyclic Graphs)
Arrays.asList vs new ArrayList(Arrays.asList())
Java Program to Implement AA Tree
Jackson – Decide What Fields Get Serialized/Deserialized
Guide to Java 8 groupingBy Collector
Giới thiệu Java Service Provider Interface (SPI) – Tạo các ứng dụng Java dễ mở rộng
Ways to Iterate Over a List in Java
Java Program to Implement TreeMap API
An Intro to Spring Cloud Security
Java Program to Implement Hash Tables with Linear Probing