Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;

import java.util.Arrays;
import java.util.Comparator;

import java.util.Random;

public class Main {
    public static String[] randomizeArray(String[] array) {

        Arrays.sort(array, new Comparator<String>() {

            private final Random generator = new Random();

            @Override
            public int compare(String lhs, String rhs) {
                // returns a random int between 1 and -1
                return (generator.nextInt(1) * 2) - 1;
            }
        });
        return array;
    }
}