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:
Hướng dẫn Java Design Pattern – Intercepting Filter
Create Java Applet to Simulate Any Sorting Technique
Giới thiệu thư viện Apache Commons Chain
LinkedHashSet trong Java hoạt động như thế nào?
Một số từ khóa trong Java
Java Program to Find Shortest Path Between All Vertices Using Floyd-Warshall’s Algorithm
Java Program to Find a Good Feedback Vertex Set
Java Program to Implement Quick Hull Algorithm to Find Convex Hull
Hướng dẫn Java Design Pattern – Iterator
Java – InputStream to Reader
Prevent Brute Force Authentication Attempts with Spring Security
Receive email using POP3
Java – Reader to String
Giới thiệu Google Guice – Dependency injection (DI) framework
Spring – Injecting Collections
Java Program to Implement Hash Tables
Exploring the New Spring Cloud Gateway
How to Get a Name of a Method Being Executed?
Lập trình đa luồng trong Java (Java Multi-threading)
Fixing 401s with CORS Preflights and Spring Security
Java Program to add two large numbers using Linked List
Java Program to Compute the Volume of a Tetrahedron Using Determinants
Hamcrest Collections Cookbook
Compact Strings in Java 9
Reactive WebSockets with Spring 5
Java Program to Implement Binary Search Tree
Spring Boot with Multiple SQL Import Files
Java Program to Use Above Below Primitive to Test Whether Two Lines Intersect
Vector trong Java
Introduction to the Java NIO Selector
Hướng dẫn sử dụng Lớp FilePermission trong java
Interface trong Java 8 – Default method và Static method