Random Number

Java Programming

Java Programming Examples

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

Learn more about Random Number