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:
TreeSet và sử dụng Comparable, Comparator trong java
Default Password Encoder in Spring Security 5
Debugging Reactive Streams in Java
Giới thiệu java.io.tmpdir
Java Program to Implement Sorted List
Initialize a HashMap in Java
Giới thiệu SOAP UI và thực hiện test Web Service
Java Program to Solve any Linear Equation in One Variable
How to Break from Java Stream forEach
A Quick Guide to Spring Cloud Consul
ArrayList trong java
Java Program to Implement Double Order Traversal of a Binary Tree
Java Program to Check whether Graph is a Bipartite using DFS
Java Program to implement Circular Buffer
The StackOverflowError in Java
Spring Boot - Securing Web Applications
Multipart Upload with HttpClient 4
Java Program to Perform Searching Using Self-Organizing Lists
Hướng dẫn Java Design Pattern – Proxy
Java Program to Implement Efficient O(log n) Fibonacci generator
Java Program to Implement Binary Search Tree
Hashing a Password in Java
Intro to Spring Boot Starters
Java Program to Implement Direct Addressing Tables
StringBuilder vs StringBuffer in Java
Unsatisfied Dependency in Spring
Java Program to Implement Gift Wrapping Algorithm in Two Dimensions
Hướng dẫn Java Design Pattern – Command
Java Program to Implement the One Time Pad Algorithm
The DAO with Spring and Hibernate
Java Program to Find the Shortest Path from Source Vertex to All Other Vertices in Linear Time
Java Program to Find the Median of two Sorted Arrays using Binary Search Approach