Assuming the /fox/food‐schedule.csv file exists with the specified contents, what is the expected output of calling printData() on it?
As a correct answer in Appendix, we have just option B.
I completely agree that this option is correct, because line r2
really doesn't compile. But, why line r3 was not included in the list of correct answers too?
Because it as well have a compile error, for the given code.
Tell me please, if my vision regarding the correct answers is correct or not?
Is that the Boyarsky and Selikoff book?
What was the correct answer given? Remember most people here don't have that book.
Why do you think r2 won't compile? I have found out why: readAllLines(Path) returns a List<Stream> rather than a Stream<String>. The compile‑time error occurs on r2; anything following is a continuation of the same error.
Thank you very much, for this response.
Your words really make sense to me now, and why it was chosen just B like a response, and not C too, for example.
Here is by the way, the original response from the book itself.
B. The readAllLines() method returns a List, not a Stream. Therefore, the call to flatMap() is invalid, and option B is correct. If the Files.lines() method were instead used, it would print the contents of the file one capitalized word at a time, with commas removed.
Boyarsky, Jeanne; Selikoff, Scott. OCP Oracle Certified Professional Java SE 11 Developer Complete Study Guide (p. 1172). Wiley. Kindle Edition.