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 Find the Median of two Sorted Arrays using Binary Search Approach
Send email with JavaMail
Tìm hiểu về xác thực và phân quyền trong ứng dụng
Injecting Prototype Beans into a Singleton Instance in Spring
Spring Boot - Sending Email
Java Program to Check the Connectivity of Graph Using BFS
Java Program to Generate All Subsets of a Given Set in the Lexico Graphic Order
Giới thiệu thư viện Apache Commons Chain
Display Auto-Configuration Report in Spring Boot
Java – Generate Random String
Java Program to Perform Searching Based on Locality of Reference
Java Program to Implement Euclid GCD Algorithm
Derived Query Methods in Spring Data JPA Repositories
Kết hợp Java Reflection và Java Annotations
Java Program to Find the Vertex Connectivity of a Graph
Java 8 Collectors toMap
Java Program to Check if a Matrix is Invertible
Java Program to Implement Stack API
Java Program to Implement Binomial Heap
SOAP Web service: Upload và Download file sử dụng MTOM trong JAX-WS
Java Program to Perform Uniform Binary Search
Debugging Reactive Streams in Java
Jackson – Decide What Fields Get Serialized/Deserialized
Spring Boot - Eureka Server
Introduction to Eclipse Collections
Tạo ứng dụng Java RESTful Client với thư viện Retrofit
Auditing with JPA, Hibernate, and Spring Data JPA
Java Timer
Chuyển đổi Array sang ArrayList và ngược lại
Dynamic Proxies in Java
Spring Boot - Batch Service
Introduction to Using FreeMarker in Spring MVC