This program imports the random class, makes an object of that class called dice, and use the dice object to get get random numbers between 1 and 6.
import java.util.Random; class jamesprogram { public static void main(String args[]){ Random dice = new Random(); int number; for (int count=1; count<=10; count++){ number = 1+dice.nextInt(6); System.out.println(number + " "); } } }
Outputs:
6
1
1
2
2
3
4
1
1
2