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 the One Time Pad Algorithm
Using a Mutex Object in Java
Hướng dẫn sử dụng Java Generics
Using a Custom Spring MVC’s Handler Interceptor to Manage Sessions
Circular Dependencies in Spring
Hướng dẫn Java Design Pattern – Builder
Jackson – Change Name of Field
Java Program to Implement Trie
Spring Cloud Connectors and Heroku
Lớp LinkedHashMap trong Java
Java Program to Represent Graph Using Incidence List
REST Web service: Upload và Download file với Jersey 2.x
Converting a Stack Trace to a String in Java
Exploring the Spring Boot TestRestTemplate
Comparing Long Values in Java
Xử lý ngoại lệ trong Java (Exception Handling)
Java Program to Create a Minimal Set of All Edges Whose Addition will Convert it to a Strongly Conne...
Giới thiệu về Stream API trong Java 8
Java Program to Construct K-D Tree for 2 Dimensional Data
Hướng dẫn Java Design Pattern – Memento
Java Program to add two large numbers using Linked List
Retrieve User Information in Spring Security
Spring Boot Gradle Plugin
New Features in Java 9
Spring RestTemplate Error Handling
Concrete Class in Java
How to Break from Java Stream forEach
Map Interface trong java
Sử dụng CyclicBarrier trong Java
Java Program to Implement Hamiltonian Cycle Algorithm
Guide to Guava Multimap
Java Program to Generate All Subsets of a Given Set in the Gray Code Order