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 JobStateReasons API
Guide to UUID in Java
Java equals() and hashCode() Contracts
LinkedHashSet trong java
Java Program to Implement HashMap API
Java Program to Find Location of a Point Placed in Three Dimensions Using K-D Trees
Spring MVC Async vs Spring WebFlux
Guide to the Java Clock Class
Java – Reader to InputStream
Cơ chế Upcasting và Downcasting trong java
Java Program to Implement LinkedList API
Spring Security Custom AuthenticationFailureHandler
Sending Emails with Java
Java Program to Implement Queue
Java Program to Generate Random Partition out of a Given Set of Numbers or Characters
New Stream Collectors in Java 9
Apache Tiles Integration with Spring MVC
OAuth 2.0 Resource Server With Spring Security 5
Java Program to Represent Graph Using Incidence List
Sao chép các phần tử của một mảng sang mảng khác như thế nào?
Tổng quan về ngôn ngữ lập trình java
Reversing a Linked List in Java
Iterating over Enum Values in Java
Java Program to Compute the Volume of a Tetrahedron Using Determinants
Java – Delete a File
Disable DNS caching
Spring Cloud AWS – Messaging Support
Java Program to Implement Cartesian Tree
Java Byte Array to InputStream
Java Program to Implement Tarjan Algorithm
Java Program to Give an Implementation of the Traditional Chinese Postman Problem
Login For a Spring Web App – Error Handling and Localization