If nis Random, you can use
n.ints(5, 1, 46).forEach(nums::add);
, ,
List<Integer> nums = n.ints(5, 1, 46).boxed().collect(Collectors.toList());
Random ThreadLocalRandom :
List<Integer> nums = ThreadLocalRandom.current().ints(5, 1, 46)
.boxed().collect(Collectors.toList());