Last active
January 13, 2019 16:21
-
-
Save thinkbigthings/f532a187a538a91f63d72b67ac2ae7ea to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import static java.util.stream.IntStream.rangeClosed; | |
import static java.util.stream.Collectors.toCollection; | |
List<Integer> randomList(int firstInclusive, int lastInclusive) { | |
List<Integer> numbers = rangeClosed(firstInclusive, lastInclusive).boxed().collect(toCollection(()->new ArrayList<Integer>())); | |
java.util.Collections.shuffle(numbers, new java.security.SecureRandom()); | |
return numbers; | |
} | |
// usage: randomList(1,10); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment