Android Convert List <String []> to String []

Android How to convert List<String[]> to String[] .....

+4
source share
2 answers
  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()]); } 

Usage example:

  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()); } 
+9
source

If you are trying to convert List <String> to String [], you can use List.toArray ()

+1
source

Source: https://habr.com/ru/post/1347340/


All Articles