choose At Random - Android java.util

Android examples for java.util:Random

Description

choose At Random

Demo Code


//package com.java2s;

import java.util.List;
import java.util.Random;

public class Main {
    public static final Random RANDOM = new Random();

    public static <T> T chooseAtRandom(List<T> list) {
        return list.get(RANDOM.nextInt(list.size()));
    }//from  w  w w.  ja v a  2s  .  co  m
}

Related Tutorials