random Number List by Stream - Java Lambda Stream

Java examples for Lambda Stream:Stream

Description

random Number List by Stream

Demo Code


    //package com.java2s;
    import java.util.*;
    import java.util.stream.*;
    import static java.util.stream.Collectors.*;

    public class Main {
        public static List<Double> randomNumberList(int size) {
            return (randomNumberStream(size).collect(toList()));
        }/*from   ww w  .ja va 2s.  c o m*/

        public static Stream<Double> randomNumberStream(int size) {
  return(Stream.generate(() -> Math.random()).limit(size));
}
    }

Related Tutorials