I have a resource string array that I want to put into an ArrayList, however the datatype that comes back is a String array. The string[] cannot be directly cast to ArrayList w/o receiving the following error:
Cannot cast from String[] to ArrayList
How to I convert the String[] datatype to ArrayList?
Edit
I have an adapter whose constructor takes an ArrayList and a resource string-array that I want to populate it.
If you can make do with a
List<String>(and not specifically anArrayList<String>), you can use:Otherwise, you can do this:
However, the latter is less efficient (in both time and object creation count) than the other suggested solutions. Its only benefit is that it keeps the code down to one line and is easy to comprehend at a glance.