I'm just learning the java.util.stream
API and I'm looking for a way to quickly fill up a Collection with some data.
I've come up with this code to add 5 random numbers:
List<Integer> lottery = Stream.of(random.nextInt(90), random.nextInt(90), random.nextInt(90),random.nextInt(90),
random.nextInt(90)).collect(Collectors.toList());
That would be however a problem in case I have to add hundreds of items. Is there a more concise way to do it using the java.util.stream
API?
(I could obviously loop in the ordinary way...)
Thanks