Java List Random Item pickupFromList(String[] list)

Here you can find the source of pickupFromList(String[] list)

Description

pickup From List

License

Apache License

Declaration

public static String pickupFromList(String[] list) 

Method Source Code

//package com.java2s;
//License from project: Apache License 

import java.util.Random;

public class Main {
    private static final Random _RAND = new Random(System.currentTimeMillis());

    public static String pickupFromList(String[] list) {
        return list[getRandomNumberBelow(list.length)];
    }//from  w  ww  .j  ava 2s  .  c o m

    public static int getRandomNumberBelow(int limit) {
        return _RAND.nextInt(limit);
    }
}

Related

  1. pickNAtRandom(List vals, int n, long seed)
  2. pickOneAtRandom(List list)
  3. PickRandom(final Collection list)
  4. pickRandom(LinkedList list, int n)
  5. pickRandom(List collection)
  6. resampleWithReplacement(final List l, final int n)
  7. sample(List l, Random r)
  8. sample(Random random, List list)
  9. sampleRandomSublist(List list, int sampleSize)