HashSet.toArray

Returns an array containing all of the elements in this set. If this set makes any guarantees as to what order its elements are returned by its iterator, this method must return the elements in the same order.

<p>The returned array will be "safe" in that no references to it are maintained by this set. (In other words, this method must allocate a new array even if this set is backed by an array). The caller is thus free to modify the returned array.

<p>This method acts as bridge between array-based and collection-based APIs.

@return an array containing all the elements in this set

  1. Object[] toArray()
    class HashSet
    Object[]
    toArray
    ()
  2. Object[] toArray(Object[] a)

Meta