Java examples for Collection Framework:Array Random Value
fill an array Randomly
//package com.java2s; import java.util.Random; public class Main { /**//from ww w . j a v a 2 s . c om * @author TheMrMilchmann * @since DerpieLang v1.0.0 */ public static final <T> T[] fillRandomly(T[] from, T[] into) { return fillRandomly(from, into, System.currentTimeMillis()); } /** * @author TheMrMilchmann * @since DerpieLang v1.0.0 */ public static final <T> T[] fillRandomly(T[] from, T[] into, long seed) { Random random = new Random(seed); for (int i = 0; i < into.length; i++) { into[i] = from[random.nextInt(from.length)]; } return into; } }