I am adding screenshot for some more information. I am new to Java8, kindly forgive me if I am asking a bad question. When I was doing research for input of space separated value I got this statement.
I understand that below statement takes value as 1 2 3 and returns value[1, 2, 3]as a list.
Kindly correct me if I am wrong,
Stream: is used on collection for iteration.
bufferedReader.readLine(): it reads the line as string
- replaceAll: is replacing space with
,later it gets parse into Integer and being collected into List
My doubt is when I am inputting 1 2 3 which is a string. So, is this stream first splitting the value with space then iterating on splitted value? or is it 1st parsing the value later storing the value in list later splitting value with space and removing space and replacing with ,. I am very curious, how exactly below statement is working.
List<Integer> a = Stream.of(bufferedReader.readLine().replaceAll("\\s$", "").split(" "))
.map(Integer::parseInt)
.collect(toList());
[1]: https://i.stack.imgur.com/nlXxd.jpg