Code for Random Number generator between the given range using Math.random() | Selenium Training|Java|WebDriver|TestNG|Frameworks|Videos

Selenium Training Forum

Code for Random Number generator between the given range using Math.random()

A
Aswin Venkattachalam Post on 03/10/2019

S

Instructor

Support Team Reply on 09/10/2019

Please refer the below code and make sure that you provide the min value and max values correctly

		Random rand = new Random();
		int minValue = 100;
		int maxValue = 103;
		int rangeForGenerator = maxValue - minValue; 
		int generatedNumber = rand.nextInt(rangeForGenerator) + minValue;
		System.out.println(generatedNumber);