The problem
In this exercise display all the prime numbers between 2 and 1,000, inclusive. Display eight prime numbers per line. Numbers are separated by exactly one space.
Breaking it down
Creating a range of numbers using java 8 IntStream and filtering numbers in stream calling a method that will check if the number is prime will leave us with a list of numbers. Next since the requirements of the exercise stated to show eight per line, we can split the list which will leave a List
of List
of a size of eight.