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

Subscribe

* indicates required
Subscribe to plus2net

    plus2net.com



    Post your comments , suggestion , error , requirements etc here




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