Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

import java.util.Random;

public class Main {
    public static void main(String[] args) {
        long[] numbers = new long[] { 1, 2, 3, 4, 5 };
        Random id = new Random(numbers.length);

        String[] name = new String[] { "a", "b", "c", "d", "e" };

        for (int i = 0; i < numbers.length; i++) {
            int randomPosition = id.nextInt(4);
            long temp = numbers[i];
            numbers[i] = numbers[randomPosition];
            numbers[randomPosition] = temp;
        }

        for (int i = 0; i < name.length; i++) {
            int randomPosition = id.nextInt(4);
            String temp = name[i];
            name[i] = name[randomPosition];
            name[randomPosition] = temp;
        }
        for (int i = 0; i < numbers.length; i++) {
            System.out.println(i + " ID = " + numbers[i] + " and name = " + name[i]);
        }
    }
}