package aster;
import java.util.*;
public class master{
public static void main(String[] args) {
ArrayList<Object> arl=new ArrayList<Object>();
Integer i1=new Integer(10);
Integer i2=new Integer(20);
Integer i3=new Integer(30);
Integer i4=new Integer(40);
String s1="tapan";
System.out.println("The content of arraylist is: " + arl);
System.out.println("The size of an arraylist is: " + arl.size());
arl.add(i1);
arl.add(i2);
arl.add(s1);
System.out.println("The content of arraylist is: " + arl);
System.out.println("The size of an arraylist is: " + arl.size());
arl.add(i1);
arl.add(i2);
arl.add(i3);
arl.add(i4);
Integer i5=new Integer(50);
arl.add(i5);
System.out.println("The content of final arraylist is: " + arl);
System.out.println("The size of an final arraylist is: " + arl.size());
Integer size = new Integer(arl.size());
String []num = new String[size];
//array list to array
arl.toArray(num);
for(int i=0;i<size;i++)
System.out.println("Array Value: " + num[i]);
}
}
where am i going wrong i am getting this error
Exception in thread "main" java.lang.ArrayStoreException
at java.lang.System.arraycopy(Native Method)
at java.util.ArrayList.toArray(Unknown Source)
at aster.master.main(master.java:32)