ArrayList and toArray()

Hello,

I have an ArrayList:

ArrayList<javax.mail.SearchTerm> terms = new ArrayList<javax.mail.SearchTerm>();

I add terms to this list and then try to build an AndTerm():

SearchTerm query = new AndTerm((SearchTerm[]) terms.toArray());

It compiles fine but Tomcat barfs.

Thanks in advance.

[342 byte] By [SLMa] at [2007-11-26 22:41:28]
# 1
that's too bad. I hope it gets sorted out soonwhat I mean is: you haven't asked a question, or even explained what "tomcat barfs" means. whats an AndTerm()?
georgemca at 2007-7-10 11:56:23 > top of Java-index,Java Essentials,Java Programming...
# 2
Sorry. This is in the logs for the line where I attempt to instantiate the AndTerm:java.lang.ClassCastException: [Ljava.lang.Object;
SLMa at 2007-7-10 11:56:23 > top of Java-index,Java Essentials,Java Programming...
# 3

How does it barf, that is not a very helpful description.

also, try this

ArrayList<SearchTerm> terms = new ArrayList<SearchTerm>();

SearchTerm query = new AndTerm(terms.toArray(new SearchTerm [terms.size()]));

SomeoneElsea at 2007-7-10 11:56:23 > top of Java-index,Java Essentials,Java Programming...
# 4
That fixed it. Thanks, George.
SLMa at 2007-7-10 11:56:23 > top of Java-index,Java Essentials,Java Programming...
# 5
> That fixed it. Thanks, George.it wasn't me. it was someone else :-)
georgemca at 2007-7-10 11:56:23 > top of Java-index,Java Essentials,Java Programming...
# 6
Well, you're useless, George. :-PAnd thanks to SomeoneElse instead!Take care
SLMa at 2007-7-10 11:56:23 > top of Java-index,Java Essentials,Java Programming...
# 7
> Well, you're useless, George. :-P> > And thanks to SomeoneElse instead!> > Take carehey......
georgemca at 2007-7-10 11:56:23 > top of Java-index,Java Essentials,Java Programming...