Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;

public class Main {
    /**
     * Pick a random index from a list of items
     * @param items - the collection of data
     * @return a index value between 0 and n-1
     */
    @SafeVarargs
    public static <T> int randomIndex(T... items) {
        int picked = (int) (Math.random() * items.length);
        return picked;
    }
}