User Tools

Site Tools


java:lang:math:random

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

java:lang:math:random [2013/04/16 08:28] (current)
188.102.43.32 created
Line 1: Line 1:
 +====== Math.random() ======
 +<code java>
 +Math.random() double;
 +</code>
 +
 +generate a 'double' random number
 +
 +===== example of Math.random in java =====
 +<code 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
 +     
 + }
 +}
 +
 +</code>
 +
 +=== 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 Datenschutz