I think I used to know how to do this once upon a time, but that was a while ago. I have a vector full of string objects, and I need to turn it into a String array.
String[] sarray = vector.toArray();
Doesn’t work because the vector method is outputing an Object array instead of a String array. I’ve tried casting it like this:
String[] sarray = (String[])vector.toArray();
And even though that will compile, it produces an error at run time.
Exception in thread “main” java.lang.ClassCastException: java.util.Arrays$ArrayList
Is there something simple I’m overlooking, or do I simply need to use a loop to step through the vector and assign elements to the string array element by element? Thanks :).