Skip to content

Instantly share code, notes, and snippets.

@thinkbigthings
Last active January 13, 2019 16:21
Show Gist options
  • Save thinkbigthings/f532a187a538a91f63d72b67ac2ae7ea to your computer and use it in GitHub Desktop.
Save thinkbigthings/f532a187a538a91f63d72b67ac2ae7ea to your computer and use it in GitHub Desktop.
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