I would like to know how to convert a 2 dimensional array into a 1 dimensional array. I have come up with some code but it doesn\'t exactly seem to work. Can someone please
A cleaner version:
public static String[] flatten(String[][] data) { List toReturn = new ArrayList(); for (String[] sublist : Arrays.asList(data)) { for (String elem : sublist) { toReturn.add(elem); } } return toReturn.toArray(new String[0]); }