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:
Spring Security – security none, filters none, access permitAll
Multi Dimensional ArrayList in Java
Handle EML file with JavaMail
Java InputStream to String
Sắp xếp trong Java 8
Java Program to Use rand and srand Functions
Java Program to Find Second Smallest of n Elements with Given Complexity Constraint
Spring REST API + OAuth2 + Angular
Wrapper Classes in Java
Java Program to Implement Segment Tree
XML-Based Injection in Spring
Get and Post Lists of Objects with RestTemplate
Java Program to Find the GCD and LCM of two Numbers
Converting a Stack Trace to a String in Java
Basic Authentication with the RestTemplate
Pagination and Sorting using Spring Data JPA
Giới thiệu JDBC Connection Pool
Supplier trong Java 8
Receive email using POP3
Java Program to Repeatedly Search the Same Text (such as Bible by building a Data Structure)
Tránh lỗi ConcurrentModificationException trong Java như thế nào?
Array to String Conversions
Java Web Services – JAX-WS – SOAP
Java 8 and Infinite Streams
Java Program to Check Whether a Directed Graph Contains a Eulerian Path
How to Change the Default Port in Spring Boot
Quick Guide to Spring MVC with Velocity
HttpClient Timeout
Spring Boot Tutorial – Bootstrap a Simple Application
Java Program for Douglas-Peucker Algorithm Implementation
Hướng dẫn Java Design Pattern – Command
Logout in an OAuth Secured Application