Zahl zwischen 0 und 1
double zufallszahl = Math.random();
Zahl von 1 bis und mit 6 
int wuerfelZahl = (int) (Math.random() * 6) + 1;
Math.random() |
0.1 |
0.2 |
0.3 |
0.4 |
0.5 |
0.6 |
0.7 |
0.8 |
0.9 |
1.0 |
* 6 |
0.6 |
1.2 |
|
2.4 |
3.0 |
|
4.2 |
|
5.4 |
|
+ 1 |
1.6 |
2.2 |
|
3.4 |
4.0 |
|
5.2 |
|
6.4 |
|
(int) |
1 |
2 |
|
3 |
4 |
|
5 |
|
6 |
|