Java Programing laungage

java.util Projects

java.util Project 1

Generating Random Number

In our application many places we are need random numbers to fulfill our requirements. In Java, the utility package provides classes which is help us in generation of random numbers for our application. Random Number is the frequently used for generating numbers which can be in the range or without range.

Previous Home Next

This Random class of java.util package can be used for generation of a random number in the range. but If you do not want to mention the range value then program will generate any random number without range.

Methods and APIs Explanation


Random is the class of java.util.*; package. This class is used to create a random number which is modified by the linear congruential formula.


It is used to return the random number into the random number generator. if we give the value in method then it return the random number within range otherwise return any random number.


package r4r;
import java.util.*;
public class randomnumbertest {
public static void main(String[] args)
Random ran=new Random();
int range=ran.nextInt(3);
System.out.println("The Random number in Range"+range);
int Norange=ran.nextInt();
System.out.println("The Random number without Range"+Norange);


The Random number in Range2
The Random number without Range1354873879

Previous Home Next