User Tools

Site Tools


Sidebar

Programming Reference/Librarys

Question & Answer

Q&A is closed







java:lang:math:random
click
to support this page (eg 0,42 € or so) Thanks.

Math.random()

Math.random() double;

generate a 'double' random number

example of Math.random in java

package codereferececomjava;
 
public class CodeRefereceComJava {
 
 
    public static void main(String[] args) {
 
        double randomDigit;
        randomDigit = Math.random();
        System.out.println(randomDigit); // random number as double
        System.out.println(randomDigit*1000+1); //double random number between 1-1000
        System.out.println((int)(randomDigit*1000+1)); //double random number between 1-1000
 
 }
}

output of Math.random()

   0.362427879998085
   363.427879998085
   363
advertising
java/lang/math/random.txt · Last modified: 2013/04/16 08:28 by 188.102.43.32

Impressum