Java List create with random value via Stream
import java.util.List; import java.util.stream.Collectors; import java.util.stream.Stream; public class Main { public static void main(String[] args) { List<Double> list = randomNumberList(10); System.out.println(list);/*from w w w . j a v a2 s .c om*/ } public static List<Double> randomNumberList(int size) { return (randomNumberStream(size).collect(Collectors.toList())); } public static Stream<Double> randomNumberStream(int size) { return (Stream.generate(() -> Math.random()).limit(size)); } }