Very simple stuff here, casting a string array to an object array and back to another string array, works fine
 
    String[] strArray1 = new String[]{"A","B","C"};
    Object[] objArray1 = (Object[])strArray1;
    String[] strArray2 = (String[])objArray1;
 
 
Now, a vector that calls toArray() that returns an array of objects, but when you cast that array to one of strings it throws a ClassCastException
 
    Vector v = new Vector();
    v.addElement("A");
    v.addElement("B");
    v.addElement("C");
 
    Object[] objects = v.toArray();
    String[] strings = (String[])objects; /* blows up here */
 
What's the difference between the last two lines of each section of code.
 
Thanks for the help,
Jeremy

Reply via email to