I\'m attempting to retrieve n unique random elements for further processing from a Collection using the Streams API in Java 8, however, without much or any luck.
Mor
You can use limit to solve your problem.
http://docs.oracle.com/javase/8/docs/api/java/util/stream/Stream.html#limit-long-
Collections.shuffle(collection); int howManyDoYouWant = 10; List smallerCollection = collection .stream() .limit(howManyDoYouWant) .collect(Collectors.toList());