I have an array of String
s and I'm looking to be able to do something along the lines of
String[] arrayOfStrings = {"this", "is", "an", "array", "of", "strings"};
List<String> listOfStrings = new ArrayList<String>( arrayOfStrings );
or
List<String> listOfStrings = new ArrayList<String>();
listOfStrings.addAll( arrayOfStrings );
I know I can do both of these if my strings are already in a collection, and also that I can iterate through the array and add them individually, but that one's a little bit messy.
Is there any way to initialise a List
(or any collection for that matter) with an array?