Random Number

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

Comments (0)

  • To add your comment please or

We use cookies to improve your experience on our site and to show you personalised advertising. Please read our cookie policy and privacy policy.

Got It!