Java Programming

Random Number

Java example for generate random number for strong password generation

9/10/2021
0 views
random-number.javaJava
import java.io.*;
import java.util.Random;

class random_number {
	public static void main(String args[ ]) {
		int no;

		/* Create object of Random class */
		Random rn = new Random();

		/* Generate random number from 1 to 10 */
		no = rn.nextInt(10) + 1;
		System.out.println("Random Number: "+no);
	}
}



/* Output */
Random Number: 4

/* ------------------------- */

Random Number: 6
Random numberGenerate random numberJava tutorial

Related Examples

Mashable is a global, multi-platform media and entertainment company For more queries and news contact us on this
Email: info@mashablepartners.com