Machine-translated by Google. Questions are authored in English.
Top

Discussion

Which of these statements about what Collections.addAll offers over repeated calls to add is correct?

  • A.It creates a new collection containing the supplied elements.
  • B.It adds elements only if they are not already present.
  • C.It merges two maps, resolving duplicate keys in favour of the second.
  • D.It appends a varargs sequence of elements to an existing collection in one call.

Answer: D

It is a convenience for pouring a handful of values, or another array, into a collection you already have, and it returns whether the collection changed. Creating a populated collection is a constructor's job, or Arrays.asList wrapped in one.

No comment is present. Be the first to comment.
Loading…

Post your comment

Please log in or register to post a comment.