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:
Giới thiệu Java Service Provider Interface (SPI) – Tạo các ứng dụng Java dễ mở rộng
Các kiểu dữ liệu trong java
Java Program to Perform Encoding of a Message Using Matrix Multiplication
Đồng bộ hóa các luồng trong Java
Java Program to Convert a Decimal Number to Binary Number using Stacks
Java Program to Find the GCD and LCM of two Numbers
Java Program to Solve the Fractional Knapsack Problem
Java Program to Implement Bit Array
Java Program to Implement Shell Sort
Default Password Encoder in Spring Security 5
An Intro to Spring Cloud Vault
Java Program to Perform Insertion in a BST
Java Program to Implement First Fit Decreasing for 1-D Objects and M Bins
Spring Boot - Admin Server
Model, ModelMap, and ModelAndView in Spring MVC
Guide to Spring Cloud Kubernetes
CharSequence vs. String in Java
Spring MVC Async vs Spring WebFlux
ThreadPoolTaskExecutor corePoolSize vs. maxPoolSize
Java Program to Implement Fermat Primality Test Algorithm
Performance Difference Between save() and saveAll() in Spring Data
Autoboxing và Unboxing trong Java
Java Program to Perform Searching in a 2-Dimension K-D Tree
Adding a Newline Character to a String in Java
Java – Reader to String
Spring Cloud Bus
Check if a String is a Palindrome in Java
Guide to Java Instrumentation
Câu lệnh điều khiển vòng lặp trong Java (break, continue)
How to Return 404 with Spring WebFlux
Java Program to Use Boruvka’s Algorithm to Find the Minimum Spanning Tree
Object cloning trong java