Reputation: 1155
Android How to Convert List<String[]>
to String[]
.....
Upvotes: 5
Views: 20558
Reputation: 23169
static String[] convert(List<String[]> from) {
ArrayList<String> list = new ArrayList<String>();
for (String[] strings : from) {
Collections.addAll(list, strings);
}
return list.toArray(new String[list.size()]);
}
Example use:
public static void main(String[] args) {
List<String[]> list = new ArrayList<String[]>();
list.add(new String[] { "one", "two" });
list.add(new String[] { "three", "four", "five" });
list.add(new String[] { "six", "seven" });
String[] converted = convert(list);
System.out.print(converted.toString());
}
Upvotes: 10
Reputation: 11926
If you are trying to convert a List< String> to a String[ ], you can use List.toArray()
Upvotes: 1