62 * invocation would have no effect on the collection. For example, invoking |
62 * invocation would have no effect on the collection. For example, invoking |
63 * the {@link #addAll(Collection)} method on an unmodifiable collection may, |
63 * the {@link #addAll(Collection)} method on an unmodifiable collection may, |
64 * but is not required to, throw the exception if the collection to be added |
64 * but is not required to, throw the exception if the collection to be added |
65 * is empty. |
65 * is empty. |
66 * |
66 * |
67 * <p><a name="optional-restrictions"/> |
67 * <p><a name="optional-restrictions"> |
68 * Some collection implementations have restrictions on the elements that |
68 * Some collection implementations have restrictions on the elements that |
69 * they may contain. For example, some implementations prohibit null elements, |
69 * they may contain.</a> For example, some implementations prohibit null elements, |
70 * and some have restrictions on the types of their elements. Attempting to |
70 * and some have restrictions on the types of their elements. Attempting to |
71 * add an ineligible element throws an unchecked exception, typically |
71 * add an ineligible element throws an unchecked exception, typically |
72 * <tt>NullPointerException</tt> or <tt>ClassCastException</tt>. Attempting |
72 * <tt>NullPointerException</tt> or <tt>ClassCastException</tt>. Attempting |
73 * to query the presence of an ineligible element may throw an exception, |
73 * to query the presence of an ineligible element may throw an exception, |
74 * or it may simply return false; some implementations will exhibit the former |
74 * or it may simply return false; some implementations will exhibit the former |
230 * String[] y = x.toArray(new String[0]);</pre> |
230 * String[] y = x.toArray(new String[0]);</pre> |
231 * |
231 * |
232 * Note that <tt>toArray(new Object[0])</tt> is identical in function to |
232 * Note that <tt>toArray(new Object[0])</tt> is identical in function to |
233 * <tt>toArray()</tt>. |
233 * <tt>toArray()</tt>. |
234 * |
234 * |
|
235 * @param <T> the runtime type of the array to contain the collection |
235 * @param a the array into which the elements of this collection are to be |
236 * @param a the array into which the elements of this collection are to be |
236 * stored, if it is big enough; otherwise, a new array of the same |
237 * stored, if it is big enough; otherwise, a new array of the same |
237 * runtime type is allocated for this purpose. |
238 * runtime type is allocated for this purpose. |
238 * @return an array containing all of the elements in this collection |
239 * @return an array containing all of the elements in this collection |
239 * @throws ArrayStoreException if the runtime type of the specified array |
240 * @throws ArrayStoreException if the runtime type of the specified array |