I have this code:
java.util.List<String> result = new java.util.LinkedList<>();
And have added some strings to it.
But I want to return a String[]. Ideally I'd like to write
return (String[])result.toArray();
But I get a casting error at runtime. (Cannot convert Object[] to String[]). Is there a way round this that doesn't involve manual element by element copy?
toArray(T[] arr).