Programming Tutorials Browser Tutorials Articles Struts Tutorials Hibernate Tutorials

  Tutorial: Summary: Math.random() and java.util.Random

Math.random() method

Tutorial Details:

A standard way to generate random numbers is to use the Math.random() method, which returens a double value in the range 0.0 up to, but not including 1.0. You can used multiplication to expand the range, addition to shift the range, and casting to convert it to an integer. The advantage of this method over the Random class (see below) is that there is no need to create an object. The disadvantage is that you often have to do more work to translate the return value into a range you want.

double Math.random()
Returns a number x in the range, 0.0 <= x < 1.0.


 

Rate Tutorial:
http://www.roseindia.net/java/java-tips/summaries/summary-random.shtml

Read Tutorial at: Click here to view the tutorial

Rate Tutorial:
Summary: Math.random() and java.util.Random

View Tutorial:
Summary: Math.random() and java.util.Random

Related Tutorials:

Site navigation
 

 

Send your comments, Suggestions or Queries regarding this site at roseindia_net@yahoo.com.

Copyright © 2006. All rights reserved.