Hi!
I'm trying to create String array from ArrayList. This task seems to be trivial, however I have a problem because of using "interface". The code and error message are shown below. Please, give me some advices to solve this problem. Thanks!
public class Class1
{
public List<myInterface> getAllTasks()
{
List<myInterface> subjects = new ArrayList<myInterface>();
...
return subjects;
}
}
public interface myInterface
{
...
}
// THIS CODE PRODUCES THE ERROR MESSAGE SHOWN BELOW
Class1 myClass = new Class1();
List<myInterface> listOfTasks = myClass.getAllTasks();
Exception in thread "main" java.lang.ArrayStoreException
at java.lang.System.arraycopy(Native Method)
at java.util.ArrayList.toArray(Unknown Source)
at org.cellfex.test.gui.MySoft$1.<init>(MySoft.java:71)
at org.cellfex.test.gui.MySoft.initComponents(MySoft.java:70)
at org.cellfex.test.gui.MySoft.<init>(MySoft.java:26)
at org.cellfex.test.gui.MySoft.main(MySoft.java:183)