Java ThreadLocalRandom getRandomTarget(List targets)

Here you can find the source of getRandomTarget(List targets)

Description

get Random Target

License

Open Source License

Declaration

public static <T> T getRandomTarget(List<T> targets) 

Method Source Code

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

import java.util.List;
import java.util.concurrent.ThreadLocalRandom;

public class Main {
    public static <T> T getRandomTarget(List<T> targets) {
        int randomIndex = ThreadLocalRandom.current().nextInt(targets.size());
        return targets.get(randomIndex);
    }//w w  w .j  a  v a  2s.  c o m
}

Related

  1. getRandomIntegerElement(List list)
  2. getRandomNumbers(Integer startNumber, Integer endNumber, Integer pageSize, Integer numNumbers)
  3. getRandomPassword()
  4. getRandomStr(int len)
  5. getRandomString(int length)
  6. getRandomValue(String prefix, long maxValue)
  7. getTempPersistFileName(String baseFileName)
  8. getThreadLocalRandom()
  9. isRandomOccurrence(int pcLikelihood)