Android How to Convert List<String[]>
to String[]
.....
In Java, a string is an object that represents a number of character values. Each letter in the string is a separate character value that makes up the Java string object. Characters in Java are represented by the char class. Users can write an array of char values that will mean the same thing as a string.
We use the toString() method of the list to convert the list into a string.
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());
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With