random number in java android between a range

Опубликовано: 11 Февраль 2026
на канале: Computer Science lectures and tutorials
2,155
8

random number in java android between a range
Hi, in this tutorial you will learn how to genrate random
number within a range in java.
the class you will use is Random and it is present in
java.util package.
First we will import it.
Then we will print 10 random numbers.
you can see there are 10 random numbers
we will set a upper bound to it. let the upper bound of the random sequence be 50.
now the 10 random numbers lie below 50.
lets fix a lower bound to it.
the lower bound be 25.
you can see there is 10 random number between range 25 to 50.

please subscribe our channel.
THanks for watching.
Code:
import java.util.Random;;
System.out.println(rnd.nextInt(max-min+1)+min);