From: "Bip Thelin" <[EMAIL PROTECTED]>
> Try exchange "return (Hashtable[]) stuff.toArray()" with:
> "return (Hashtable[]) stuff.toArray(new Hashtable[0])" It should do the
trick.
This is more efficient:
return (Hashtable[]) stuff.toArray(new Hashtable[stuff.size()]);
because the data will be put in the same array you pass to toArray(). In
the previous code, the data can't fit in the zero-element parameter, so
toArray() creates a new array, using the parameter only to know the type.
This creation uses reflection, so it's even slower than a normal new.
And the following is even faster (by a hair):
Hashtable ret = new Hashtable[stuff.size()];
stuff.toArray(new Hashtable[ret]);
return ret;
because you avoid the evil typecheck.
===========================================================================
To unsubscribe: mailto [EMAIL PROTECTED] with body: "signoff JSP-INTEREST".
Some relevant FAQs on JSP/Servlets can be found at:
http://java.sun.com/products/jsp/faq.html
http://www.esperanto.org.nz/jsp/jspfaq.html
http://www.jguru.com/jguru/faq/faqpage.jsp?name=JSP
http://www.jguru.com/jguru/faq/faqpage.jsp?name=Servlets