Given the code fragment:



Assume the courses.txt is accessible.

Which code fragment can be inserted at line n1 to enable the code to print the content of the courses.txt file?

A.

B.

C.

D.

題解

選項A,Files類別的list方法會回傳Stream物件,所以會編譯錯誤。

選項B,Files類別的readAllLines方法會回傳List物件,所以會編譯錯誤。

選項C,readAllLines方法前應該指定Files類別。

選項D,正確答案。