On Wed, 14 Dec 2005 05:44:29 GMT, "Mike Schilling"
<mscottschilling@hotmail.com> wrote, quoted or indirectly quoted
someone who said :
>Ugly? It does the same calculation the caller would make to create one of
>the proper size. i.e. call emails.size()..
here is the code:
public <T> T[] toArray(T[] a) {
if (a.length < size)
a = (T[])java.lang.reflect.Array.newInstance(
a.getClass().getComponentType(), size);
int i = 0;
Object[] result = a;
for (Entry<E> e = header.next; e != header; e = e.next)
result[i++] = e.element;
if (a.length > size)
a[size] = null;
return a;
}
If you don't provide the array the proper size, you use reflection to
create the new array, vs plain new to create it if you do provide it.

Signature
Canadian Mind Products, Roedy Green.
http://mindprod.com Java custom programming, consulting and coaching.
Mike Schilling - 14 Dec 2005 06:23 GMT
> On Wed, 14 Dec 2005 05:44:29 GMT, "Mike Schilling"
> <mscottschilling@hotmail.com> wrote, quoted or indirectly quoted
[quoted text clipped - 22 lines]
> If you don't provide the array the proper size, you use reflection to
> create the new array, vs plain new to create it if you do provide it.
Thanks, I'd never looked at that code before, but now that you show it, it's
pretty obvious that that would be required.