Method random()
Return type: double
Member of:
java.lang.Math
[
api documentation
] [
main menu
]
Examples of how the element is used
(one line per example):
[
add your own example
]
1
return new BigDecimal(Math.random());
2
int index = (int)(Math.random()*list.size());
3
int waitTime = (int)(Math.random() * (double)time);
4
return new Double(Math.random());
5
return (float)Math.random();
6
requiredSecret=Double.toString(Math.random());
7
return (int)(255 * Math.random());
8
super(""+(Math.round(Math.random()*10000)));
9
int i = (int) Math.floor(Math.random() * items.length);
10
Thread.currentThread().sleep(100 + (int)(100*Math.random()) );
11
ret.addValue("random", String.valueOf(Math.random()));
12
long delay = (long)(Math.random() * RESOLVE_PERIOD);
13
ret = (int) (Math.random() * (hi - lo + 1));
14
Double D = new Double(Math.random() * 100.0);
15
long delay=_scavengerPeriod+Math.round(Math.random()*_scavengerPeriod);
16
a = (int)(Math.random() * _programme.size());
17
return Long.toString(java.lang.Math.round(java.lang.Math.random()*(max-min)));
18
cacheId = 10000 * (1 + Math.round (Math.random () * 8)) + Math.round (Math.random () * 1000);
19
g.setColor(new Color((int) (Math.random() * 0xFFFFFFL)));
20
(((int)(Math.random() * 256) % 5) == 4))
Java and J2SE are trademarks or registered trademarks of Sun Microsystems, Inc. in the United States and other Countries.