First, there is an arraylist like this.
Arraylist mylist = new arraylist ();
Then there is such an interface in the system and a class that implements this interface.
Interface IArticle
Class article implements IArticle
Add an article instance to the previous arraylist.
Mylist. Add (new article ());
Then, you want to convert mylist to the form of IArticle [] and return the returned value. The purpose is to make the function return value strongly typed (this is not required after the Java 5 model is created)
I did this first
IArticle [] Articles = (IArticle []) mylist. toarray ();
The result is a classcastexception.
After a long time, I suspected rpwt, and finally Google found that this was a problem caused by lack of understanding of language differences (in memory, C # Is OK)
IArticle [] Articles = (IArticle []) mylist. toarray (new article (mylist. Size ());
Now, OK ......