So I've created an IntStream where I give it a range of 1 - 9. I would like to be able to use the map function to take each element in the given range (1-9) and randomise each one.
Essentially I would like to stream the numbers 1 - 9 in a different order each time the program is ran. (I'm open to other ideas, but it has to be using streams).
I've heard about using Java's Random class but i'm not sure how i would implement that over a map of each element.
I've tried doing this but there are errors:
IntStream.range(1, 9).map(x -> x = new Random()).forEach(x -> System.out.println(x));
Any help would be appreciated.