Java Random Element randomElementOf(String[] array)

Here you can find the source of randomElementOf(String[] array)

Description

random Element Of

License

Open Source License

Declaration

private static String randomElementOf(String[] array) 

Method Source Code

//package com.java2s;
//License from project: Open Source License 

import java.util.Random;

public class Main {
    private static String randomElementOf(String[] array) {
        int size = array.length;
        return array[random(size)];
    }/*  www.  java  2s .c  o  m*/

    private static int random(int max) {
        return new Random().nextInt(max);
    }
}

Related

  1. randomElement(int[] anArray)
  2. randomElement(List list)
  3. randomElement(T... values)
  4. randomElement(T[] array)
  5. randomElementOf(final List list)
  6. randomEles(List list, int count)