R

Ram Sharma • 3.40K Points
Extraordinary

Q. What is the purpose of using `Collectors.toUnmodifiableList()`?

  • (A) To get a synchronized list
  • (B) To get a list that can be modified later
  • (C) To get a read-only list that cannot be modified
  • (D) To get a null-safe list
  • Correct Answer - Option(C)
  • Views: 13
  • Filed under category Java
  • Hashtags:

Explanation by: Ram Sharma
`Collectors.toUnmodifiableList()` returns an immutable list; attempts to modify it will throw `UnsupportedOperationException`.

You must be Logged in to update hint/solution

Discusssion

Login to discuss.

Be the first to start discuss.