Java List Random Item sample(List l, Random r)

Here you can find the source of sample(List l, Random r)

Description

sample

License

Open Source License

Declaration

public static <E> E sample(List<E> l, Random r) 

Method Source Code

//package com.java2s;

import java.util.List;

import java.util.Random;

public class Main {
    public static <E> E sample(List<E> l, Random r) {
        int i = r.nextInt(l.size());
        return l.get(i);
    }//from w  w w  . j a va 2  s  . co m
}

Related

  1. PickRandom(final Collection list)
  2. pickRandom(LinkedList list, int n)
  3. pickRandom(List collection)
  4. pickupFromList(String[] list)
  5. resampleWithReplacement(final List l, final int n)
  6. sample(Random random, List list)
  7. sampleRandomSublist(List list, int sampleSize)
  8. sampleWithoutReplacement(List items, int sampleSize)
  9. sampleWithReplacement(final Random random, final List data, final int sampleSize)