Math.random()

Returns a double greater than or equal to 0.0 and less than 1.0 .
Syntax
Math.random()
Output is a double.
	System.out.println(Math.random()); 
Output will be 0.7, different each time we run the above code.

Random number over a range of Numbers

We can specify a range, say 100 to 200 and get random numbers between them.
int max=200, min=100;
System.out.println((int) (Math.random() * (max-min)+1)+min);
All Math functions
Java


plus2net.com






We use cookies to improve your browsing experience. . Learn more
HTML MySQL PHP JavaScript ASP Photoshop Articles Contact us
©2000-2025   plus2net.com   All rights reserved worldwide Privacy Policy Disclaimer