Spaces:
Running
Running
File size: 537 Bytes
5c6ac75 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 |
Java API = Java's ready-made libraries
https://docs.oracle.com/en/java/javase/11/docs/api/index.html
Random class
nextInt(int maximum) returns a random number between [0, maximum)
https://docs.oracle.com/en/java/javase/11/docs/api/java.base/java/util/Random.html
import java.util.Random;
public class Example {
public static void main(String[] args){
Random rnd = new Random();
for (int i=0; i<5; i++) {
System.out.println(rnd.nextInt(6) + 1);
}
}
}
Example output:
5
4
3
4
6
|