Here you can find the source of mergeStringArrays(String[][] arrayOfArrays)
public static String[] mergeStringArrays(String[][] arrayOfArrays)
//package com.java2s; import java.util.ArrayList; public class Main { /**/*from www . j a va 2 s . c o m*/ * Merges an array of string arrays to a concatenated * string array. * Concatenation is done in the following order * arrayOfArrays[0][0],arrayOfArrays[0][1] ... arrayOfArrays[1][0] ... arrayOfArrays[x][z] * if arrayOfArrays is <code>null</code> the method return string array with length 0. * any <code>null</code> value in <code>arrayOfArrays</code> is skipped. */ public static String[] mergeStringArrays(String[][] arrayOfArrays) { if (arrayOfArrays == null) { return new String[0]; } ArrayList<String> res = new ArrayList<String>(); for (int i = 0; i < arrayOfArrays.length; i++) { if (arrayOfArrays[i] == null) { continue; } for (int j = 0; j < arrayOfArrays[i].length; j++) { if (arrayOfArrays[i][j] != null) { res.add(arrayOfArrays[i][j]); } } } return res.toArray(new String[res.size()]); } }