/** * Returns an array containing all of the elements in this composite. * * @return an object array of all the elements in the collection */ @Override public Object[] toArray() { final Object[] result = new Object[size()]; int i = 0; for (final Iterator<E> it = iterator(); it.hasNext(); i++) { result[i] = it.next(); } return result; }