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:
Phương thức tham chiếu trong Java 8 – Method References
Java Program to Check Whether it is Weakly Connected or Strongly Connected for a Directed Graph
Retrieve User Information in Spring Security
Spring Boot Application as a Service
Java Program to Describe the Representation of Graph using Adjacency Matrix
Java Program to Implement LinkedHashSet API
Java Program to Implement Hash Tables Chaining with List Heads
Spring Boot - Application Properties
Lớp lồng nhau trong java (Java inner class)
Java Program to Find Transpose of a Graph Matrix
Converting String to Stream of chars
Java Program to Implement Skip List
Java Program to Find the Shortest Path Between Two Vertices Using Dijkstra’s Algorithm
Spring 5 and Servlet 4 – The PushBuilder
Most commonly used String methods in Java
Java Streams vs Vavr Streams
Serverless Functions with Spring Cloud Function
Java Program to Implement Branch and Bound Method to Perform a Combinatorial Search
Java Program to Solve Set Cover Problem assuming at max 2 Elements in a Subset
Spring Boot Integration Testing with Embedded MongoDB
Receive email using IMAP
Java 8 – Powerful Comparison with Lambdas
Sort a HashMap in Java
Returning Custom Status Codes from Spring Controllers
Java Program to Perform Search in a BST
A Guide to ConcurrentMap
Chuyển đổi Array sang ArrayList và ngược lại
How to Get a Name of a Method Being Executed?
Hướng dẫn Java Design Pattern – Factory Method
Set Interface trong Java
RegEx for matching Date Pattern in Java
Mapping Nested Values with Jackson