Question 16
Back to Exercise
Why can't a Function<Path, String> lambda call Files.readString(p) directly?
- A Files cannot be used in lambdas
- B Function.apply declares no checked exceptions, but readString throws IOException; catch it or use an interface that declares it Correct
- C Path is not serializable
- D It can
Correct Answer: Option B
Callable.call(), by contrast, declares throws Exception.
Discussion & Comments 0
Share your method, a shortcut, or ask about a step you didn't follow.
No comments yet. Be the first to share your solution!