To generate random numbers java users Random class and to generate integer random number nextInt(maxNo) of Random number is used the parameter maxNo specifies that this method generate a integer number between 0 and maxNo.
1 2 3 4 5 6 7 8 9 10 11 12 | import java.util.Random; public class RandomNumber { public static void main(String[] args) { int maxno=100; Random randomNo = new Random(); int no = randomNo.nextInt(maxno); System.out.print("random number is :" + no); } } |
It will generate random number between 0 and 100, where 0 and 100 are included