I am working on creating an array of strings from a list of strings. So far, I have the following code:
ArrayList<String> layerChoices = new ArrayList<>();
for(IFeatureLayer layer : layerList){
layerChoices.add(layer.getName());
}
String[] choices = (String[])layerChoices.toArray();
The issue being that toArray() returns an Object[] and not a String[] which is producing a class cast exception when trying to cast to a String[]. Is there a simple way to accomplish my goals other than a for loop in which I would iterate through the Object[] , cast each Object to a String, and then add each String to a String[]? Seems like a lot of work for a simple task...