I tried
String[] arr = (String[])vector.toArray();
I got a runtime error pointing to that line saying:
Exception in thread "main" java.lang.ClassCastException
I do know that the object[] = .... would work but I don't want to have to do that. The goal of my method is to sort a vector of strings alphabetically. I am passing the method a vector. I then want to convert it to an array. Use the arrays built-in sort algorithms to sort the array and then put the items back into a vector in sorted order and return it.
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.