8.582
Bearbeitungen
Jneug (Diskussion | Beiträge) |
Jneug (Diskussion | Beiträge) |
||
| Zeile 365: | Zeile 365: | ||
|} | |} | ||
=== java.util.Random === | === {{Java API|java.util.Random}} === | ||
Hilfsklasse, um Zufallswerte verschiedener Typen zu erzeugen. | |||
{| {{prettytable}} | {| {{prettytable}} | ||
| Zeile 373: | Zeile 375: | ||
|- | |- | ||
| Zufällige ganze Zahl von <code>0</code> bis <code>max-1</code> erzeugen. | | Zufällige ganze Zahl von <code>0</code> bis <code>max-1</code> erzeugen. | ||
| {{ | | {{Java API|java.util.Random|nextInt-int-|int nextInt(int max)}} | ||
| <syntaxhighlight lang="java"> | | <syntaxhighlight lang="java"> | ||
Random rand = new Random(); | Random rand = new Random(); | ||
| Zeile 380: | Zeile 382: | ||
|- | |- | ||
| Zufälligen Wahrheitswert erzeugen. | | Zufälligen Wahrheitswert erzeugen. | ||
| {{ | | {{Java API|java.util.Random|nextBoolean--|boolean nextBoolean()}} | ||
| <syntaxhighlight lang="java"> | | <syntaxhighlight lang="java"> | ||
Random rand = new Random(); | Random rand = new Random(); | ||
| Zeile 387: | Zeile 389: | ||
|- | |- | ||
| Zufällige Zahl zwischen 0 und 1 erzeugen, wobei 1 niemals erzeugt wird (exklusive). | | Zufällige Zahl zwischen 0 und 1 erzeugen, wobei 1 niemals erzeugt wird (exklusive). | ||
| {{ | | {{Java API|java.util.Random|nextDouble--|double nextDouble()}} | ||
| <syntaxhighlight lang="java"> | | <syntaxhighlight lang="java"> | ||
Random rand = new Random(); | Random rand = new Random(); | ||