Hi,
Apologies if the below question has already been answered.
I need to generate n
random integers for one of my use cases. I am trying to find the right/ better way to do that. I have the following 2 implementations in my mind -
Implementation 1
Random rand = new Random();
List<Integer> list = IntStream.range(0, n).mapToObj(i -> Workflow.sideEffect(Integer.class, rand::nextInt)).toList();
Implementation 2
Random rand = new Random();
List<Integer> list = Workflow.sideEffect(List.class, IntStream.range(0, n).mapToObj(rand::nextInt)::toList);
Which one is better and why?