Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

import java.util.Arrays;
import java.util.Random;

public class Main {

    public static void main(String[] args) {
        int[] nums = new int[100];

        for (int i = 0; i < nums.length; ++i) {
            nums[i] = i + 1;
        }

        Random generator = new Random();
        for (int i = 0; i < nums.length; ++i) {
            int arrayIndex = generator.nextInt(nums.length - i);
            int tmp = nums[nums.length - 1 - i];
            nums[nums.length - 1 - i] = nums[arrayIndex];
            nums[arrayIndex] = tmp;
        }
        System.out.println(Arrays.toString(nums));
    }

}