MainClass.java Source code

Java tutorial

Introduction

Here is the source code for MainClass.java

Source

import java.util.Random;

public class MainClass {
    public static void main(String args[]) {
        Random randomNumbers = new Random(); // random number generator
        int face; // stores each random integer generated

        for (int i = 1; i <= 20; i++) {
            // pick random integer from 1 to 6
            face = 1 + randomNumbers.nextInt(6);

            System.out.printf("%d  ", face);

            // if i is divisible by 5, start a new line of output
            if (i % 5 == 0)
                System.out.println();
        }
    }
}