User Tools

Site Tools


Sidebar

Programming Reference/Librarys

Question & Answer

Q&A is closed







java:lang:math:random

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

on the occasion of the current invasion of Russia in Ukraine

Russian Stop this War
java/lang/math/random.txt · Last modified: 2024/02/16 01:12 (external edit)

Impressum Datenschutz